C++ compilers for os x and linux

Carlis

Senior member
May 19, 2006
237
0
76
Hi

I am to do some mathematical programming/simulations this spring and I don't want to use fortran since my own computer don't really agree with my labs about what the source should look like.

Now, I would like to be able to work on and test my source both on my own computer, a mac (G4) as well as the computers at the lab (x86 linux).

I have never worked with any C-language before. My impression is that c++ is very much standardized. Do I have to take any special precautions (like choice of compilers) to have 100% compatible source? I am up to mathematical programming, so it will only write logic stuff.

Regards, Carlis
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Luckily Linux and OS X are quite similar. I would recommend you use g++ as your compiler, stick as strongly as you can to standard C++, and only use posix library calls.
 

Cogman

Lifer
Sep 19, 2000
10,286
147
106
Seconded degibson's opinion. GCC is a pretty good free compiler and should be able to do everything you need.

If you need more speed, remember to change the compiler options to optimize for the system you are using (IE, -O3 -march=nocona -vectorize-trees -funroll-loops ect). If that doesn't do it for you, give the ICC a try. It generally performs better the gcc in most compiling situations (and I think they have a mac version as well) The professional version of the ICC isn't free, but the personal/non-commercial version is.
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Originally posted by: Cogman
Seconded degibson's opinion. GCC is a pretty good free compiler and should be able to do everything you need.

If you need more speed, remember to change the compiler options to optimize for the system you are using (IE, -O3 -march=nocona -vectorize-trees -funroll-loops ect). If that doesn't do it for you, give the ICC a try. It generally performs better the gcc in most compiling situations (and I think they have a mac version as well) The professional version of the ICC isn't free, but the personal/non-commercial version is.

Don't use -march=nocona unless both target machines are Core 2 Duo.