Can I compile generic code using GCC for Macports?

Since Apple does not support GCC 4.6 or GCC 4.7, I just switched to building GCP 4.6 / 4.7 MacPorts. However, I had a problem creating my code in a "universal" architecture.

Traditionally, I would do g++ -arch i386 -arch x86_64 ...to compile my binary code, at least for the i386 / x86_64 architecture. I did a search and realized that the -arch option is only supported by Apple compilers. So, of course, he did not work with Macports. The best I could do was use the -m32/ options -m64to specify the architecture I want. However, this will lead to the creation of a binary file in either i386 format or x86_64 format. I really want to get the binary in both architectures (Universal), as was done with the original GCC compilers.

Is this a problem or is it unknown? I tried all night to search for answers on Google, but I did not get anything useful. So I just doubt that I only have one problem, and I missed something really important to make it work? Really appreciate if anyone can give me some suggestions.

BTW. I installed the options gcc46 +universal, but did not create anything truly universal, except compiling separate binaries for each architecture.

Xing.

+5
source share
2 answers

You can combine binaries with different architectures in one universal, using lipo .

+3
source

, . , GCC 4.2.1 , ( , -arch), lipo . , macports GCC, -arch ( 32- 64- Intel ).

, :

http://thecoderslife.blogspot.com/2015/07/building-with-gcc-46-and-xcode-4.html

+6

All Articles