eclipse-cdt如何与静态库链接 [英] eclipse-cdt how to link with static library

查看:231
本文介绍了eclipse-cdt如何与静态库链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑我应该在链接器/库下设置库还是在路径和符号下设置它们。我认为他们是一样的。我正确吗?

Fist i am confused should i set libraries under Linker/Libraries or to set them under "path and symbol". i think that they are the same. am i correct?

我的问题有任何办法-我需要链接静态库,所以我尝试了一些事情:

any way for my question - i need to link static library , so i tried few things:

首先尝试,我尝试在链接库中添加gtest(这是库)和gtest路径。
以这种方式编译并链接正确,但是在运行时失败,因为当它尝试加载共享库(我要静态库!)时,错误是

First try I try to add gtest (this is the library) and gtest path in the link library. in this way its compiled and linked correct , but failed in runtime , because when it tried to load shared library (i want static library !) error is


加载共享库时出错:libgtest.so.0

error while loading shared libraries: libgtest.so.0

第二次尝试-我尝试在路径和符号中定义它,并将完整的路径'/root/workspace/gmock/gtest/lib/.lib/libgtest.a'添加到库中。在这种情况下,我在链接中出错:

Second try - I try do define it in path and symbol add to libraries the complete path '/root/workspace/gmock/gtest/lib/.lib/libgtest.a' . in this case i got error in the linkage :

g++ -L/root/workspace/gmock/lib/.libs -L/root/workspace/gmock/gtest/lib/.libs -o "playground"  ./src/p.o ./src/playground.o   -lpthread -l/root/workspace/gmock/gtest/lib/.lib/libgtest.a -l/root/workspace/gmock/lib/.lib/libgmock.a
/usr/bin/ld: cannot find -l/root/workspace/gmock/gtest/lib/.lib/libgtest.a

没有给出答案,也没有解释如何定义静态链接与共享链接的区别。

This post dosnt give an answer and not explain how you define differently linked against static vs shared.

谢谢

推荐答案

经过大量研究,没有相关答案。找到了!!!
我在
此eclipse-cdt的有用链接

After lot of research and not related answer. found it!!! I found it in this useful link for eclipse-cdt

显然,该库需要存在于工作区中。

Apparently the library need to exist in the workspace.

这篇关于eclipse-cdt如何与静态库链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆