eclipse 如何消除链接器错误 mingw32/bin/ld.exe:找不到 -lSDL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41755327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how do I eliminate linker error mingw32/bin/ld.exe: cannot find -lSDL
提问by user121903
I am trying to build SDL
for use with Eclipse. I am trying to remove this linker error:
我正在尝试构建SDL
以与 Eclipse 一起使用。我正在尝试删除此链接器错误:
Beginning Compilation
开始编译
21:15:53 **** Incremental Build of configuration Debug for project CMD ****
Info: Internal Builder is used for build
g++ "-IC:\MinGW\include\SDL2" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\CMD.o" "..\src\CMD.cpp"
g++ -o CMD.exe "src\CMD.o" -lmingw32 -lSDL -lSDL2main -lSDL2
ERROR(s):
错误:
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL collect2.exe: error: ld returned 1 exit status 21:15:54 Build Finished (took 1s.36ms)
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe:找不到-lSDL collect2.exe:错误: ld 返回 1 退出状态 21:15:54 构建完成(花费 1s.36ms)
The most pertinent SO archive source I researcheddidn't seem to have an actionable answer for my problem, though it had the exact same problem/error: title -- producing the same error message:
我研究过的最相关的 SO 存档源似乎没有针对我的问题提供可操作的答案,尽管它具有完全相同的问题/错误:标题——产生相同的错误消息:
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL.
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe:找不到-lSDL。
If you click to the authors "solution" for the same error as mine its not clear to me how he solved it.
如果您单击作者的“解决方案”以获取与我相同的错误,我不清楚他是如何解决它的。
Any help?
有什么帮助吗?
回答by user121903
Problem solved, SDL2 awesome. Ok:
问题解决了,SDL2真棒。好的:
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL.
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe:找不到-lSDL。
Reinstallation of SDL2 avoiding binary conflict between SDL files and SDL2 files as keltar mentioned resolved the immediate problem, and the problem built with no errors!Fixing what was in the braces unmasked new problem: crashing. I stripped the program to bare bones and concluded the crashing was outside of the code since it was occurring even without code.
重新安装 SDL2 避免了 SDL 文件和 SDL2 文件之间的二进制冲突,正如 keltar 提到的那样解决了眼前的问题,并且问题没有出现错误!修复大括号中的内容暴露了新问题:崩溃。我将程序剥离到裸露的骨头,并得出结论,崩溃不在代码范围内,因为即使没有代码,它也会发生。
To solve the new problem would need to go the SDL2 distribution file (the one copied to MinGW) and copy the SDL2.dll from it [DLL from distributable][1]--- by dragging the file over your debug and/or release folders where the .exe file lives.(.exe + dll -> right?) moving dll to exes. Build/Run the program it should work! You should see a Welcome message! https://www.caveofprogramming.com/c-for-complete-beginners/setting-up-sdl-windows.html
要解决新问题,需要转到 SDL2 分发文件(复制到 MinGW 的文件)并从中复制 SDL2.dll [DLL from distributable][1]---通过将文件拖到调试和/或发布上.exe 文件所在的文件夹。(.exe + dll -> 对吗?)将 dll 移动到 exes。构建/运行它应该工作的程序!您应该会看到欢迎消息! https://www.caveofprogramming.com/c-for-complete-beginners/setting-up-sdl-windows.html