简体   繁体   English

Mingw和Eclipse无法找到库

[英]Mingw and Eclipse unable to find library

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. 我创建了一个新项目,在Eclipse中添加了库路径,并添加了要使用的库的名称。 But the MingW linker can't find the library. 但是MingW链接器找不到该库。 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. 在mingw文档中找不到任何有效的内容。

My command is as follows: 我的命令如下:

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

The file is called test.a 该文件称为test.a

In command line I tried using 在命令行中,我尝试使用

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

But this didn't help either. 但这也无济于事。

I installed MingW and Make for Windows. 我安装了MingW和Make for Windows。 I added both of those to my PATH variable. 我将它们都添加到了PATH变量中。

name it libtest.a and use -ltest option to g++. 将其命名为libtest.a并使用g ++的-ltest选项。 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)). * nix中的静态库(包括mingw)应该被命名为libxxx.a-l选项告诉编译器在指定路径中查找库(当前路径和通过-L选项提供)。 but to link w/ static lib one may give a fullname (w/o any option)... just pass libtest.a 但是链接w /静态lib可能会给出一个全名(不带任何选项)...只需传递libtest.a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM