C++ MinGW/Eclipse ld.exe 找不到库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9127623/
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
MinGW/Eclipse ld.exe does not find libraries
提问by TheSHEEEP
I am using Eclipse CDT to try to compile a project with the Ogre 3D engine. But somehow mingw is not able to find the static libraries I link against.
我正在使用 Eclipse CDT 尝试使用 Ogre 3D 引擎编译项目。但不知何故 mingw 无法找到我链接的静态库。
These are the error messages:
这些是错误消息:
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot find -lzziplib_d
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot find -lzlib_d
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot find -lfreetype_d
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe:找不到-lzziplib_d
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe:找不到-lzlib_d
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe:找不到-lfreetype_d
...etc. The list goes on like this for each library.
...等等。每个库的列表都是这样的。
As you can probably see, I already am aware of the (IMO) weird "lib" and ".a" additions the ld.exe seems to make automatically. The libraries are all named correctly. So for example, the "freetype_d" really is "libfreetype_d.a".
正如您可能看到的,我已经知道 ld.exe 似乎自动添加了(IMO)奇怪的“lib”和“.a”。这些库都被正确命名。例如,“freetype_d”实际上是“libfreetype_d.a”。
I have also added the correct paths to the libraries before, like this:
我之前还添加了正确的库路径,如下所示:
-L"C:\Coding\Ogre\make-debug\sdk\lib\Debug\" -L"C:\Coding\Ogre\make-debug\sdk\lib\Debug\opt\"
-L"C:\Coding\Ogre\make-debug\sdk\lib\Debug\" -L"C:\Coding\Ogre\make-debug\sdk\lib\Debug\opt\"
And each library file is in one of these two folders.
每个库文件都在这两个文件夹之一中。
This is my full command line as displayed by Eclipse CDT:
这是 Eclipse CDT 显示的完整命令行:
g++ -L"C:\Coding\Ogre\make-debug\sdk\lib\Debug\" -L"C:\Coding\Ogre\make-debug\sdk\lib\Debug\opt\" -o "OgreTestMinGW" ./BaseApplication.o ./LowLevelOgre.o -lzziplib_d -lzlib_d -lfreetype_d -lFreeImage_d -lOIS_d.dll -lOgreMainStatic_d -lOgrePagingStatic_d -lOgrePropertyStatic_d -lOgreRTShaderSystemStatic_d -lOgreTerrainStatic_d -lRenderSystem_GLStatic_d -lPlugin_ParticleFXStatic_d -lPlugin_PCZSceneManagerStatic_d -lPlugin_OctreeZoneStatic_d -lPlugin_OctreeSceneManagerStatic_d -lPlugin_CgProgramManagerStatic_d -lPlugin_BSPSceneManagerStatic_d
g++ -L"C:\Coding\Ogre\make-debug\sdk\lib\Debug\" -L"C:\Coding\Ogre\make-debug\sdk\lib\Debug\opt\" -o "OgreTestMinGW" ./BaseApplication.o ./LowLevelOgre.o -lzziplib_d -lzlib_d -lfreetype_d -lFreeImage_d -lOIS_d.dll -lOgreMainStatic_d -lOgrePagingStatic_d -lOgrePropertyStatic_d -lOgreRTShaderSystemStatic_d -lOgreTerrainStatic_d -lRenderSystem_GLStatic_d -lPlugin_ParticleFXStatic_d -lPlugin_PCZSceneManagerStatic_d -lPlugin_OctreeZoneStatic_d -lPlugin_OctreeSceneManagerStatic_d -lPlugin_CgProgramManagerStatic_d -lPlugin_BSPSceneManagerStatic_d
What am I missing here?
我在这里缺少什么?
回答by Janek Olszak
On Windows, when you add libraries path "-L" and click "File System" Eclipse gives you the path with "\", change those to "/" and it shall work!
在 Windows 上,当您添加库路径“-L”并单击“文件系统”时,Eclipse 会为您提供带有“\”的路径,将它们更改为“/”,它将起作用!
回答by Igore Vitaller
looks like you should try to remove "_d" from library names and add -DDEBUG . Also, debug libraries can be stored in a separate ogre directory.
看起来您应该尝试从库名称中删除“_d”并添加 -DDEBUG 。此外,调试库可以存储在单独的 ogre 目录中。