简体   繁体   中英

What's the OSX equivalent to Linux g++-multilib?

I'm new to this and i'm trying to link a 64 bit compiled filed to a 32 bit object file but i get this error:

ld: warning: ignoring file Estudiant.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 1 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): Estudiant.o Undefined symbols for architecture x86_64:

I think i need to install what in linux is the g++-multilib but i can't find the equivalent for osx. Does anyone know how to solve this problem?

On both Linux and OS X you can only either link all 64 bit object files and libraries together, or all 32 bit object files and libraries. Regarding libraries, the two operating systems use different approaches to manage the co-existence of 32 and 64 bits.

On Linux, the multilib-approach is used, where there is bot a 32 bit and a 64 bit version of the same library, usually with the same name but located in two different directories, eg /lib and /lib64.

On OS X, the fat-binary approach is used, where a single library or executable contains both the 32 bit and 64 bit object files, all in a single file (a couple of years ago there would be libraries that contained up to 4 different versions of everything, PPC 32, PPC 64, x86 32, x86 64).

That's why there is no direct equivalent to multilib on OS X, you don't have multiple libraries just because you need both 32 and 64 bits!

To build an application, you need to consistently build all of your object files as either 32 bit or 64 bit (like on Linux, you can't mix on either system) and then, well, hope that all the libraries that are used contain (at least) the version that you need. Otherwise you need to start looking into building the required libraries, but most everything that comes with the system should support both 32 and 64 bits.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM