链接器在同一目录中找不到静态库
我正在将一些 Visual Studio 2008/VC9 内容移植到 Code::Blocks/MinGW,由于某种原因,链接器无法从工作区中的另一个项目找到静态库。
在 Visual Studio 2008 中,我只需将静态库项目设置为依赖项,它将按正确的顺序构建(即需要在链接其他项目之前构建静态库),并链接正确的配置库。
我在 Code::Blocks 中找不到这样的选项,因此我确保首先显式构建静态库(libcommon.a),然后在另一个项目的“构建选项”下在“链接器”中添加“libcommon.a”设置”。 .a 文件与项目文件位于同一目录中,但是我仍然从其他项目的链接器收到错误,说他们找不到它......
ld.exe 找不到 -lcommon
我在做什么,所以它找不到该库,即使它就在项目文件旁边?
还有更好的方法来模拟单个解决方案/工作区中的 Visual Studio 依赖项吗?
I'm porting some Visual Studio 2008/VC9 stuff to Code::Blocks/MinGW and for some reason the linker cannot find a static library from another project in the workspace.
In Visual Studio 2008 I could just set the static lib project as a dependency, and it would build in the right order (i.e. static lib needs to be built before linking the other project), and link the correct library for the configuration.
I couldn't find such an option in Code::Blocks, so I made sure to explicitly build the static lib first (libcommon.a) then under "build options" for the other project add "libcommon.a" in the "linker settings". The .a file is located in the same directory as the project files, however I still get an error from the linker of the other projects saying they cant find it...
ld.exe cannot find -lcommon
What am I doing so it cant find the library, even though its right next to the projects file?
Also is there a better way to simulate the Visual Studio dependencies within a single solution/workspace?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,包含项目文件的目录不包含在链接器搜索路径中,需要通过将“.\”添加到包含项目库文件的目录列表中来显式定义。
Apparently the directory containing the project files is not included in the linker search path, and needed to be defined explicitly by adding ".\" to the list of directories containg library files for the projects.