问题描述
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 选项告诉编译器在指定的路径(当前和通过
-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无法找到库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!