Simple Note created on Jun 02 - 2009 9:07 PM on Cross-compile on Mac OS X

for Win32 and Linux

Compile Win32 exe on Mac OS X

use the older version,
since Tiger is born in 2007, use the version minGW 3.4.5.

use MinGW 4.3.0 above for Mac OS X and newer;

Check the sample code of the related compiler's download page, like

g++ -o hello.out hello.cpp
g++ file1.cpp file2.cpp file3.cpp 	# for multiple file into one program
g++ -o lab7.out file1.cpp file2.cpp file3.cpp

Compile Linux binary on Mac OS X

  1. not much problem
  2. install i386-linux-gcc 4.1.1 above for Mac OS X (Intel) or newer at the same page above
  3. the output of the binary program is a.out

Issue and Problems

  • “libiconv.2.dylib 7.0.0 version not found” problem on Mac OS X 10.4.
    Because the Tiger use version 5 of that library, so new compiler born at Leopard time may expect version 7, so use a old version compiler on Tiger can solve the problem.
  • No new line at end of file when compiling Linux
    Because there is “end of line tag” needed as \n on Unix;
    while mac os use \r, thus, press an extra return in code for Linux.


set Path environment Method 1:

  1. open .profile
  2. export PATH=$PATH:/new_path_entry
  3. add above and close