If you use Xcode you might know that making universal binaries (programs) is easy just by modifying the project properties. But for the most part I don't use Xcode I mainly use the terminal to compile. In this case the solution is quite easy too.
I made a Hello World application in C. Usually I will compile using
g++ Hello.cpp
the result is an executable file named a.out (17 Kb in size) that will run on my Mac Book Pro, if I try to run this code in my mac mini an error will occur. Using the flag -arch we can specify a different architecture, i.e.
g++ Hello.cpp -flag ppc
the result is once again an executable named a.out (20 Kb in size), this code will run in the mac mini natively. It will also run on the Intel mac but it will not be native reducing the performance of the code.
Finally if we want to run this code on natively on both PPC and Intel we would use the following command
g++ Hello.cpp -flag i386 -flag ppc
the result is an executable a.out (40 Kb in size), that contains both a PPC native and a Intel native binary.
This flag option is exclusive to mac platform, so it won't work on Linux machines. I try running each one of the 3 executables produced on a Linux machines, as expected no one worked.
I have been having trouble using the GSL (Gnu Scientific Library) and generating universal binaries, my best guess is that I have to compile the libraries again for PPC but I don't have the time, energy nor patience to do it.
No comments:
Post a Comment