如何将一个库静态链接到另一个静态库? [英] How do I statically link a library into another static library?

查看:121
本文介绍了如何将一个库静态链接到另一个静态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个具有不同版本的MinGW的构建环境:一个为Qt配置,另一个没有.但是,两者都具有Qt的存根静态库(最终实际上链接到dll).问题是我想在Qt MinGW中建立一个静态库,然后将其包含在非Qt MinGW中.尝试时出现以下链接错误:

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'

我发现Qt MinGW正在动态链接到标准库,并且我需要包括选项-static-libgcc.但是,我不知道在哪里使用它,因为我不是在构建可执行文件,而是在构建静态库.

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.

推荐答案

静态库只是对象文件的集合-存档.您不是通过链接而是通过归档程序(通常是ar)来创建它.要将另一个静态库的目标文件包含在一个新的静态库中,您必须找到归档程序要合并它们的相关选项.

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.

这篇关于如何将一个库静态链接到另一个静态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆