[英]link static lib in eclipse cdt
I am sorry! 对不起! I have googled this a lot and cannot find an answer!
我搜索了很多,但找不到答案! It's dumb I know.
我知道这是愚蠢的。
I cannot link in static libraries(*.a) in eclipse cdt. 我无法在eclipse cdt中链接静态库(* .a)。 I listed them all in Project->Settings-> GCC C++ linker -> Libraries.
我在项目 - >设置 - > GCC C ++链接器 - >库中列出了它们。 I used the absolute path to make sure I had the lib correct... and i get:
我使用绝对路径来确保我的lib正确...我得到:
cannot find -l/usr/local/lib/libboost_date_time.a 找不到-l / usr / local / lib / libboost_date_time.a
I am sure it's stupid whatever I am doing wrong :( 无论我做错什么,我都确定这是愚蠢的:(
Edit -- and i should mention i am linking the libraries at run time... 编辑 - 我应该提到我在运行时链接库...
I remember having a similar issue way back when I was compiling our code under linux (coming from a windows background) and if I recall correctly specifying the absolute path to the static lib also didn't work. 我记得当我在linux下编译我们的代码(来自windows背景)时有一个类似的问题,如果我记得正确指定静态库的绝对路径也没有用。
Are you aware that to link to "libboost_date_time.a", you need to specify "boost_date_time" without the "lib" and the ".a"? 您是否知道要链接到“libboost_date_time.a”,您需要指定“boost_date_time”而不使用“lib”和“.a”? In my case that solved the problem.
在我的情况下解决了这个问题。 /usr/local/lib should be on your path in any case AFAIR.
无论如何,/ usr / local / lib应该在你的道路上。
Static libraries or archives are just a collection of object files. 静态库或归档只是目标文件的集合。
Add the archive as Other Objects under C/C++ Build -> Settings -> C++ Linker -> Miscellaneous : 在C / C ++ Build - > Settings - > C ++ Linker - > Miscellaneous下添加存档作为其他对象 :
Some folks cry bloody murder over specifying a full pathname. 有些人因为指定一个完整的路径名而哭泣。 I find it works in practice (unlike theory at times), and its no worse than breaking the path and filename , and then specifying them with
-L
and -l
. 我发现它在实践中有效(有时与理论不同),它并不比打破路径和文件名差 ,然后用
-L
和-l
指定它们。 And did I mention it actually works in practice... 我是否提到它实际上在实践中有效...
I had the similar problem when adding the libs in the C/C++ General->Paths & Symbols
configuration screen. 在
C/C++ General->Paths & Symbols
配置屏幕中添加lib时,我遇到了类似的问题。
Instead on the C/C++ Build -> settings
screen under GCC C++ Linker / Libraries
I added the library name without lib and .a
in Libraries (-l) and adding the path in Libraries search path (-L)
. 而不是在
GCC C++ Linker / Libraries
下的C/C++ Build -> settings
屏幕上,我在库(-l)中添加了没有lib和.a
的库名,并在库搜索路径(-L)
添加了路径。 This solved my problem 这解决了我的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.