在iPhone上使用boost

4

经过很多hack,我成功地为iPhone编译了boost库,包括设备和仿真器。但是当我尝试使用它们时,Xcode调试器会报错:

dyld: Library not loaded: libboost_graph.so.1.40.0

我猜测这是一个动态库加载器,在iPhone上不被允许。我使用-Lboost_graph作为编译器标志链接应用程序。
以下是我用于构建Boost的脚本:
./bjam $1 $2 $3 \
        toolset=darwin \
        architecture=arm \
        target-os=iphone \
        macosx-version=iphone-3.0 \
        define=_LITTLE_ENDIAN \
        --layout=system \
        --libdir=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib \
        --includedir=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include \
        link=static \
        runtime-link=static

./bjam $1 $2 $3 \
        toolset=darwin \
        architecture=x86 \
        target-os=iphone \
        macosx-version=iphonesim-3.0 \
        --layout=system \
        --libdir=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib \
        --includedir=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/include \
        link=static \
        runtime-link=static

我猜我可能错过了一些非常基础的东西,但是错过了什么呢?
这个库是否编译为动态加载(在平台/usr/lib中有一个.a文件和一个.so文件)?

你最终解决了这个问题吗? - Ben Collins
请参考以下相关答案:https://dev59.com/OHI-5IYBdhLWcg3w-96b - Alejandro
1个回答

2

我可能错了,但是我认为你需要将应用程序静态链接到boost——来自dyld的错误消息表明你目前正在链接到动态boost库(请注意错误消息中的.so后缀——你希望链接到静态库libboost.a)。

你可能想要使用类似以下的方式链接你的应用程序:

-iboost_graph -static

(假设.a文件名为libboost_graph.a

似乎使用-static链接会使编译器退回到另一个链接器,导致出现另一个错误:“ld_classic:找不到文件:-lcrt0.o”至少我有另一个编译器标志可以搜索 :) - possan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接