g++ linker order question
I am trying to figure out 开发者_高级运维something that is causing an error when trying to compile code in Qt Creator, that is linking in my externally built libraries.
It is complaining about an "undefined reference to myclass::myclass(args)" constructor.
However, this class has been built, and the object file was included in an archive called common.a .
The code that references myclass is actually in another library, called CSV.a
So, I know my Qt project can see CSV.a, and I know that there are other references to stuff in common.a that it is not complaining about, but apparently the stuff in CSV.a can't see the stuff in common.a in this arrangement.
What do I need to do differently?
The linker uses the order that libraries are listed on the command line to determine which symbols are actually needed. You need to order them from most-dependent to least-dependent so it can make that determination. For example, list CSV.a
first so the compiler knows that it needs to find myclass::myclass(args)
somewhere. Then list common.a
second and the compiler will then find and link that constructor.
You may need to make sure that on the linker command line CSV.a
is followed by common.a
, not the other way around.
精彩评论