Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
63 Views

multiple duplicate symbol errors when linking a dylib with static lib using "-all_load" linker flag in Xcode7

Hi,

I am getting these type of linkage error when linking with a static library from a dylib with "-all_load" linker flag:

duplicate symbol ___acosdq in:
    /p4client/ProAudio/dev_main/ProAudio/XcodeBuildProducts/Debug/Native/libInstrumentCommonNative.a(__acosdq_iface.o)
    /usr/local/bin/icpc-16.0.146-base/compiler/lib/libimf.a(__acosdq_iface.o)
duplicate symbol ___acoshq in:
    /p4client/ProAudio/dev_main/ProAudio/XcodeBuildProducts/Debug/Native/libInstrumentCommonNative.a(__acoshq_iface.o)
    /usr/local/bin/icpc-16.0.146-base/compiler/lib/libimf.a(__acoshq_iface.o)
duplicate symbol ___acosq in:
    /p4client/ProAudio/dev_main/ProAudio/XcodeBuildProducts/Debug/Native/libInstrumentCommonNative.a(__acosq_iface.o)
    /usr/local/bin/icpc-16.0.146-base/compiler/lib/libimf.a(__acosq_iface.o)
duplicate symbol ___annuityq in:
    /p4client/ProAudio/dev_main/ProAudio/XcodeBuildProducts/Debug/Native/libInstrumentCommonNative.a(__annuityq_iface.o)
    /usr/local/bin/icpc-16.0.146-base/compiler/lib/libimf.a(__annuityq_iface.o)
duplicate symbol ___asindq in:


My build environment is Xcode7 and I am using intel compiler 16 (Parallel Studio XE 2016 Update 3) to build both the dynamic library and the static library that it links to.

I assume the duplicate symbols error occurs because by using "-all_load" the dynamic lib loads also the intel compiler static libs and this what causes the duplicate error - if I do not specify "-all_load" everything builds successfully but tatic objects of libInstrumentCommonNative.a are not loaded in runtime. 

Ideally I would use "-force_load" flag and specify libInstrumentCommonNative.a path but the compiler complains it does not recognize "-force_load" flag.

I should state that with icc 15 I managed to solve this issue by using "-nodefaultlibs" link Flag in the static library's build target but this workaround does not seem to work with icc 16.

Is there a way to use "-force_load" or any equivalent or alternatively ignore the duplicate symbol errors?

Thanks,

Roman

0 Kudos
1 Reply
Highlighted
Beginner
63 Views

Ok,

managed to resolve the errors with these flags:

-Wl,-force_load

0 Kudos