强制链接到Xcode目标库的静态链接? [英] Force static linking of library linked to Xcode target?

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

问题描述

我的Xcode目标链接与hdf5库(使用Link Binary with Libraries构建阶段)。 libhdf5使用MacPorts安装,因此/ opt / local / lib同时包含库的动态(.dylib)和静态(.a)版本。



文本输出从构建中可以看出,正如预期的那样,在构建的链接步骤中有一个 -lhdf5 。但是,gcc似乎将动态链接库视为静态链接库。有没有办法强制gcc(通过编译器开关或通过Xcode)静态链接到libhdf5.a?



我发现的唯一解决方案是复制libhdf5 .a到项目(或其他)目录并链接到该副本,从而避免在同一位置有动态和静态版本。 解决方案

针对您对Eduard Wirch的回答的回答:您也可以仅为这个库控制静态链接,如果您将-lhdf5替换为-l / full / path / to / libhdf5.a


My Xcode target links against hdf5 library (using the Link Binary with Libraries build phase). libhdf5 is installed using MacPorts, thus /opt/local/lib contains both the dynamic (.dylib) and static (.a) versions of the library.

The text output from the build shows that there is, as expected, a -lhdf5 in the linking step of the build. gcc seems to take the dynamic linked library over the static, however. Is there any way to force gcc (via a compiler switch or via Xcode) to statically link with libhdf5.a?

The only solution I've found is to copy libhdf5.a to the project (or other) directory and link against that copy, thus avoiding having dynamic and static versions in the same location.

解决方案

In reaction to your comment on Eduard Wirch' answer: you can also control static linking for this one library only, if you replace -lhdf5 by -l/full/path/to/libhdf5.a

这篇关于强制链接到Xcode目标库的静态链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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