[英]C++: External library in eclipse CDT
Now I am using eclipse CDT for my C/C++ Application, but there is problem when I link my external library, it could not be loaded properly at run time, even through I put the library file near the source file, I gave the library path, and it's name correctly. 现在我使用eclipse CDT作为我的C / C ++应用程序,但是当我链接我的外部库时出现问题,它无法在运行时正确加载,即使我把库文件放在源文件附近,我给了库路径,它的名称正确。
project directory: 项目目录:
I want link that static libraries with my application I follow this steps: 我希望链接静态库与我的应用程序我按照以下步骤:
When I build the program it displays a error cannot find -lbozorth3.a cannot find -lLSFMatcher.a 当我构建程序时显示错误找不到-lbozorth3.a无法找到-lLSFMatcher.a
So I need the correct steps to add the external library to c/c++ application. 所以我需要正确的步骤将外部库添加到c / c ++应用程序。
I normally configure 我通常配置
(see images below and exchange the path in the Linker flags to that one you used in the library search path) (请参阅下面的图像并将链接器标记中的路径交换为您在库搜索路径中使用的路径)
you should use -Wl,-rpath=${workspace_loc}/Liball
and not -Wl,-rpath,${workspace_loc}/Liball
. 你应该使用
-Wl,-rpath=${workspace_loc}/Liball
, -Wl,-rpath=${workspace_loc}/Liball
而不是-Wl,-rpath=${workspace_loc}/Liball
, -Wl,-rpath=${workspace_loc}/Liball
-Wl,-rpath,${workspace_loc}/Liball
。
Also under library -l option add library like eg. 同样在库-l选项下添加库,例如。 for libgcc.a add only gcc
对于libgcc.a只添加gcc
You should pay attention to what is in parentheses: Other options (-Xlinker [option]). 您应该注意括号中的内容:其他选项(-Xlinker [option])。
The way to pass options is different. 传递选项的方式是不同的。 Instead of using:
而不是使用:
-Wl,-rpath,'${ProjDirPath}/../../system/lib'
You must use: 你必须使用:
-rpath '${ProjDirPath}/../../system/lib'
That is, remove the "-Wl," and replace the second "," by " " (space). 也就是说,删除“-Wl”,并用“”(空格)替换第二个“,”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.