Link libraries with dependencies in Visual C++ without getting LNK4006

后端 未结 9 1966
难免孤独
难免孤独 2020-12-16 10:56

I have a set of statically-compiled libraries, with fairly deep-running dependencies between the libraries. For example, the executable X uses libraries A and B, A uses libr

9条回答
  •  难免孤独
    2020-12-16 11:48

    The problem is you are not localizing library C's symbols. So you have a ODR violation when you link in A and B. You need to have a way to make these private. By default all symbols are exported. One way to do this is to have a special linker definition file for both A and B that explicitly mention which files need to be exported.

    [1] ODR = One Definition Rule.

提交回复
热议问题