我曾经用Codeblocks创建和编译C程序。我想手动编译它,所以我尝试使用Makefile。但是,我似乎错过了一个重要的细节,因为当我执行该程序时,它会抛出我在编译Codeblocks时从未遇到过的错误:
"...cygwin1.dll is missing from your computer..."
我观看并研究了编译代码seen in Codeblocks when running the "compile" button:
mingw32-gcc.exe -Wall -g -I"D:\Program Files (x86)\CodeBlocks\SDL2\x32\include" -c "C:\Users\nounoursnoir\Desktop\dev\C\exercices\SDL Tower Defense\main.c" -o obj\Debug\main.o
mingw32-g++.exe -L"D:\Program Files (x86)\CodeBlocks\SDL2\x32\lib" -o "bin\Debug\SDL Tower Defense.exe" obj\Debug\main.o -lmingw32 -lSDL2main -lSDL2 -lSDL2_image "D:\Program Files (x86)\CodeBlocks\MinGW\lib\libmingw32.a" "D:\Program Files (x86)\CodeBlocks\SDL2\x32\lib\libSDL2main.a" "D:\Program Files (x86)\CodeBlocks\SDL2\x32\lib\libSDL2.dll.a" "D:\Program Files (x86)\CodeBlocks\SDL2\x32\lib\libSDL2_image.dll.a"
Output file is bin\Debug\SDL Tower Defense.exe with size 43.42 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
我可以做的最好的类似编译是Makefile:
FLAGS=-Wall -g
I=-I/d/Program\ Files\ \(x86\)/CodeBlocks/SDL2/x32/include
L1=-L/d/Program\ Files\ \(x86\)/CodeBlocks/SDL2/x32/lib
L2=-L/d/Program\ Files\ \(x86\)/CodeBlocks/MinGW/lib
l=-lmingw32 -lSDL2main -lSDL2 -lSDL2_image
l1="D:\Program Files (x86)\CodeBlocks\MinGW\lib\libmingw32.a"
l2="D:\Program Files (x86)\CodeBlocks\SDL2\x32\lib\libSDL2main.a"
l3="D:\Program Files (x86)\CodeBlocks\SDL2\x32\lib\libSDL2.dll.a"
l4="D:\Program Files (x86)\CodeBlocks\SDL2\x32\lib\libSDL2_image.dll.a"
CFROM="C:\Users\nounoursnoir\Desktop\dev\C\exercices\SDL Tower Defense\main.c"
OBJTO="obj\Debug\main.o"
EXETO="bin\Debug\SDL Tower Defense.exe"
main: main.o
gcc $(L1) $(L2) -o $(EXETO) $(OBJTO) $(l) $(l1) $(l2) $(l3) $(l4)
main.o: main.c
gcc $(FLAGS) $(I) -c $(CFROM) -o $(OBJTO)
运行命令make
并双击生成的可执行文件图标时,会发生上述错误,我不明白为什么,发生了什么以及如何解决它。我需要帮助才能理解这一点。
您可能会注意到,从shell Babun运行可执行文件时,它可以正常工作:./bin/Debug/SDL\ Tower\ Defense.exe
(所需的库已移入./bin/Debug以使其正常工作)。
另外,对我来说,Cygwin似乎安装在我的机器上,环境PATH变量指向它的位置:C:\Users\nounoursnoir\.babun\cygwin
。我不认为它可能遗漏任何东西。