链接静态库在另一个静态库 [英] Link static library in another static library

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

问题描述

我需要将Abaqus ODB C ++ API静态库链接到另一个静态库中。我可以得到这个工作,但我得到了很多链接器警告。所有警告都是LNK4006和LNK4221,并涉及API库。

I need to link the Abaqus ODB C++ API static library in another static library. I can get this to "work" but I get a lot of linker warnings. All of the warnings are LNK4006 and LNK4221, and concern the API libraries.

我想在主项目中链接生成的静态库。当我这样做,应用程序启动,并给我一个信息,如应用程序无法正确启动0xc000007b。

I want to link the resulting static library in the main project. When I do this, the application starts and gives me a message like The application was unable to start correctly 0xc000007b.

如果这不清楚:
API Lib - > MyProj Lib - > MainProj

If this is unclear: API Lib -> MyProj Lib-> MainProj

请参阅Paul的答案。你不能嵌套这样的静态库,如果你认为你需要,你需要了解更多关于链接阶段。

Please see the answer by Paul below. You can't nest static libraries like this and if you think you need to, you need to learn more about the linking phase. Instead, the main project needs to link both of dependent static libraries.

推荐答案

您不能将库包含在库中。你把这两个库链接到你的应用程序,这是你已经做的。你只需要遵循一个c ++程序的一般规则:只允许一个符号的定义,你需要防止潜在的名称冲突。

You can't "include a library in a library". You link both libraries to your application which is what you've apparently done already. You just have to follow the general rules of a c++ program: only one defintion of a symbol is allowed and you need to prevent potential name clashes.

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

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