How do I statically link a library into another st

2019-07-05 23:49发布

问题:

I have 2 build environments with different versions of MinGW: one configured for Qt and one not. Both, however, have the stub static libraries of Qt (which end up actually linking to the dlls). The problem is that I want to build a static library in the Qt MinGW and then include it in the non Qt MinGW. I get the following link errors when I try:

moc_browser.cpp:(.eh_frame+0x11): undefined reference to `___gxx_personality_v0'
browser.cpp:(.text+0x213): undefined reference to `__Unwind_Resume'

I found that the Qt MinGW is linking dynamically to the standard libraries and that i need to include the option -static-libgcc. However, I do not know where to use it since I am not building an executable, but rather a static library.

回答1:

A static library is just a collection of object files - an archive. You don't create it by linking, but with an archiving program (often ar). To include the object files of another static library in a new one, you have to find the relevant options for the archiving program to merge them.