redefine symbols for arm64 macOS

  arm64, c++, objcopy

I have two static third-party libraries which have same exported symbol, and all of symbols I what to use in my shared library.
objcopy can redefine symbols from library. After install binutils package from brew, extract all *.o files from static library and and call objcopy for each *.o files

objcopy --redefine-sym

pack objects with

ar r *.o

and

ranlib mylib.a

but when I try to compile dymamic library linker show warning:

mylib.a, building for iOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x23 0x31 0x2F 0x32 0x30 0x20 0x20 0x20 

If use objcopy with –output-target mach-o-arm64, linker warning transform to

mylib.a, building for iOS-arm64 but attempting to link with file built for iOS-arm64

It work for x86_64 libraries, but fiasco for arm64..

Source: Windows Questions C++

LEAVE A COMMENT