Eclipse 同时管理静态和动态链接库的 make

发布于 2024-12-24 03:38:28 字数 826 浏览 4 评论 0原文

我正在使用 Eclipse CDT 的托管 make 功能。使用仅动态库创建项目正在按预期工作。但是 boost_unit_test_framework 应该静态链接,因为它包含 main 函数。在命令行上,混合链接到动态和静态库不是问题。这是一个工作示例:

g++ -L../Debug -L../boost/lib -o "Test" ./Test.o -ldynLib -Wl,-Bstatic -lboost_unit_test_framework -Wl,-Bdynamic

dynlib 和 libc 等标准库是动态链接的,而 boost_unit_test_framework 是静态链接的。但是我如何在项目的设置中输入这些信息?我看不到任何办法。

可以在每个项目中标记该库以进行静态链接,例如在全局位置。 QNX 使用了约定([手册])。可以使用 LIBPREF_library 和 LIBPOST_library 在指定库之前或之后添加选项。

更新: 我仍然不知道如何解决所描述的问题。但与此同时,我已将构建系统从 Managed Make 切换到 CMake。另外,我现在使用 Qt Creator,因为它能够索引增强,并且在更新某些内部结构时不会冻结 UI ...

[手册] http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/prog/make_convent.html#USEMAC

I am using the managed make functionality of Eclipse CDT. Creating the project using dynamic only libraries is working as expected. But the boost_unit_test_framework should be linked statically, because it contains the main function. On the command line it is not a problem to link to dynamic and static libraries in a mixture. So this is a working example:

g++ -L../Debug -L../boost/lib -o "Test" ./Test.o -ldynLib -Wl,-Bstatic -lboost_unit_test_framework -Wl,-Bdynamic

The dynlib and the standard libraries like libc are linked dynamically and the boost_unit_test_framework is linked statically. BUT how can I enter this information in the Settings of the Project? I can not see any way.

It may be possible to flag this library in every project for static linking, for example in a global place. There is convention used by QNX ([manual]). It is possible to use LIBPREF_library and LIBPOST_library to add Options before or after the specified library.

Update:
I have still no clue how to solve the described problem. But in the meantime I have switched my build system from Managed Make to CMake. And additionally I am now using the Qt Creator because it is able to index boost and does not freeze the UI while updating some internal structures ...

[manual] http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/prog/make_convent.html#USEMAC

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

潜移默化 2024-12-31 03:38:28

我认为您不需要指定链接的类型。动态库不能静态链接,反之亦然。在我的一个项目中,在项目属性 -> 下C/C++ 构建 ->设置,我在库下列出了静态库和动态库。似乎可以弄清楚它们是什么类型,并且无论哪种方式都可以很好地链接。

I don't think you need to specify the type of linking. Dynamic libraries can't be linked statically, and vice versa. On one of my projects, under Project Properties -> C/C++ Build -> Settings, I have both static and dynamic libraries listed under Libraries. It seems to work out what type they are and link fine either way.

月光色 2024-12-31 03:38:28

动态库进入:链接器/库/库(-l)
静态库包含:链接器/杂项/其他文件和对象

Dynalic libraries goes in : Linker/Libraries/Libraries (-l)
Static libraries goes in : Linker/miscelanous/Other files and objects

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文