Link static library in another static library

旧巷老猫 提交于 2019-11-30 09:07:03

问题


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.

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.

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


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.


回答1:


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.



来源:https://stackoverflow.com/questions/12198261/link-static-library-in-another-static-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!