getopt.h: Compiling Linux C-Code in Windows

2019-01-07 11:26发布

I am trying to get a set of nine *.c files (and nine related *.h files) to compile under Windows.

The code was originally designed in Linux to take command line arguments using the standard GNU-Linux/C library "getopt.h". And that library does not apply to building the C-code in Windows.

I want to ignore what my code does right now and ask the following question. For those of you familiar with this C-library "getopt.h": will it be possible to build and run my code in Windows if it depends on POSIX-style command-line arguments? Or will I have to re-write the code to work for Windows, passing input files differently (and ditching the "getopt.h" dependency)?

8条回答
孤傲高冷的网名
2楼-- · 2019-01-07 12:22

The getopt.h exists in git, I have download it and it works for me:

https://gist.github.com/ashelly/7776712

查看更多
爷的心禁止访问
3楼-- · 2019-01-07 12:23

I did compile the getopt code under windows.

I did this as I wanted to explicilty use its command line parsing functionality in a windows (command line) app.

I successfully did this using VC2010.

As far as I remember I ran into no significant issues doing so.

getopt.c getoptl.c

查看更多
登录 后发表回答