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.

Derek
  • 1,104
  • 13
  • 35

1 Answers1

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.

Paul Michalik
  • 4,331
  • 16
  • 18
  • 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. – Derek Aug 30 '12 at 13:58
  • 2
    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". – Paul Michalik Aug 30 '12 at 14:11
  • `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`? – Derek Aug 30 '12 at 14:19
  • 3
    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 Exe`is linked. – Paul Michalik Aug 30 '12 at 15:26