Mingw and Eclipse unable to find library

情到浓时终转凉″ 提交于 2019-12-24 02:13:31

问题


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.

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

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. I added both of those to my PATH variable.


回答1:


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



来源:https://stackoverflow.com/questions/14533855/mingw-and-eclipse-unable-to-find-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!