xcode project-/target-settings-syntax for linker flag force_load on iPhone

前端 未结 2 914
野性不改
野性不改 2020-12-14 07:43

I am confronted with the double bind. On the one hand, for one of the 3rd party static libraries my iPhone application uses, the linker flag -all_load has to be

2条回答
  •  盖世英雄少女心
    2020-12-14 08:03

    I just tried this. I've compiled a static armv6, armv7, and i386 fat binary of PCRE for use in my iPhone project. My project normally just has my library added to the project and that links fine. So I unchecked the target membership box for libpcre.a and rebuilt. As expected, I get a bunch of missing symbol linker errors for the pcre symbols. Then I opened the target settings window and edited the "Other Linker Flags" section. I added:

    -force_load lib/pcre/libpcre.a
    

    The lib directory is in the same directory as my project.xcodeproj file.

    It linked fine so I know the force_load command worked (and I can see it added to the build flags when xcode builds the file).

    Hope that helps.

    Update:

    I also tried adding a system library to the "Other Linker Flags" line like so:

    -force_load src/pcre/libpcre.a -force_load ${SDKROOT}/usr/lib/libz.dylib
    

    That worked too.

提交回复
热议问题