2

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 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

4 Comments

So I can include both libraries in the main project even though one is dependent on the other? I understand that only one definition of a symbol is allowed. The API libraries are canned.
No, you have to link both libraries to the program which results from your main project. In VS you create an "executable" project type and set both libraries as "references".
MyProj Lib is dependent upon the API Lib. I can link both them in the MainProj, but how would that work when I go to build MyProj Lib?
When MyProj Lib is compiled, it (or the compiler/librarian) does not need to know where the symbols from API Lib are. It just needs to know they are declared. The symbols are required by the linker, when MainProj Exeis linked.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.