MinGW GCC wildcard

那年仲夏 提交于 2021-02-10 06:26:26

问题


I'm using MinGW GCC compiler on windows how to compile all C files in a directory.

I used

gcc  *.c -o  Output

after I entered the required folder and I got this error

gcc: error: *.c: Invalid argument 
gcc: fatal error: no input files

compilation terminated.

the used version of GCC is 4.7.1


回答1:


For anyone else like me who's come across this problem:

I ran into this problem when I installed MinGW-w64 on my tablet after having run it for a few years on my desktop.
Basically, I have a ruby script that does some basic compilation stuff for me, and it was breaking at the linking stage on my tablet (developed on, and ran fine on the desktop).
The error: Invalid Argument, no input files (as in the original question).

If you check around, you'll find a few places that tell you that the issue is due to the way CMD on Windows handles passing wildcards to programs (vs UNIX shells).
Basically Windows leaves interpretation of the wildcard up to the program.
Some builds of MinGW can handle a wildcard from CMD, whereas others won't.
I'm able to use wildcards using the MinGW-W64-builds installer for MinGW-W64.




回答2:


This should work with older mingw-w64 versions:

#ifdef __MINGW64_VERSION_MAJOR
int _dowildcard = -1; /* enable wildcard expansion for mingw-w64 */
#endif


来源:https://stackoverflow.com/questions/39360051/mingw-gcc-wildcard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!