Mingw和Eclipse无法找到库 [英] Mingw and Eclipse unable to find library

查看:316
本文介绍了Mingw和Eclipse无法找到库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题类似于这里 a>。我创建了一个新项目,在Eclipse中添加了库路径,并添加了要使用的库的名称。但是MingW链接器找不到库。我试过使用/而不是\(这是解决问题Iiked),以及其他几个,但没有运气。找不到在mingw文档中工作的任何内容。

I'm having the issues simlar to what's described here. I created a new project, added the library path in Eclipse and added the name of the library to use. But the MingW linker can't find the library. I've tried using "/" instead of "\" (this was the solution to the issue Iiked to), as well as several other things, but no luck. Couldn't find anything that worked in the mingw documentation.

我的命令如下:

g++ -LD:/ocv/build/x86/mingw/lib -o OCVTest.exe "src\\OCVTest.o" -ltest.a 
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot find -ltest.a
collect2.exe: error: ld returned 1 exit status

该文件名为test.a

The file is called test.a

在命令行中我尝试使用

g++ -L"D:/ocv/build/x86/mingw/lib" -o OCVTest.exe "src\\OCVTest.o" -ltest.a 

但是这也没有帮助。

我安装MingW和Make for Windows。我把它们添加到我的PATH变量。

I installed MingW and Make for Windows. I added both of those to my PATH variable.

推荐答案

将它命名为libtest.a并使用-ltest选项到g ++。
静态库在* nix(包含mingw)应该命名为 libxxx.a -l <​​/ code>选项告诉编译器在指定的路径(当前和通过 -L 选项给定)中查找库。但是链接w /静态库一个可以给一个全名(w / o任何选项)...只是传递libtest.a

name it libtest.a and use -ltest option to g++. static libs in *nix (include mingw) supposed to be named like libxxx.a, -l option tells to compiler to find libraries in specified paths (current and given via -L option(s)). but to link w/ static lib one may give a fullname (w/o any option)... just pass libtest.a

这篇关于Mingw和Eclipse无法找到库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆