compiler for c++ (thought it was g++?)

2

After installing the 'Developer Tools' from the mac os installation DVD, I can now execute gcc /path/to/input/ and create an executable shell script from .c code.

I thought the C++ compiler to create executables was g++, but when I try to use it to compile .cpp files: 'g++ /path/to/file/' it creates the expected a.out file, but when I try to run the new file, my computer uses 'Saturn' by default to open 'a.out' and says that it cannot open the file...

What is Saturn, and why can it not open 'a.out'?

Also, should I be using g++ to compile C++ files, or is there a better compiler that I could be using for that (aside from XCode)?

FALL3N

Posted 2012-02-18T23:21:05.927

Reputation: 431

2Try g++ directory/file.cpp -o file – Tomer Vromen – 2012-02-18T23:24:35.397

some C++ compilers default to require .so or .dll files at run-time, for things like object construction or exception handling. This seems like that. If so, there's probably a switch you can put in the command to cause the libraries to be statically linked into your executable. – JustJeff – 2012-02-18T23:40:00.377

Answers

2

It probably has something to do with extension of the file. Maybe the program Saturn is the default app to run this type of file for some reason. Type ./a.out in the shell after navigating to the directory the file is in, and let me know what happens. As suggested by Tomer, if you remove the *.out extension it should open from the shell automatically.

rubixibuc

Posted 2012-02-18T23:21:05.927

Reputation: 1 492

if you would like to be able to open the file by double clicking on it, set it's default application to Terminal – rubixibuc – 2012-02-19T02:09:42.997

0

yes, Tomer's idea worked, that was it.. I'm still not sure exactly what Saturn is (probably a GUI environment for C++) but it does not matter for this question, because the terminal runs the compiled C++ file now, thanks a lot!

FALL3N

Posted 2012-02-18T23:21:05.927

Reputation: 431