Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)?

share|improve this question
2  
Try g++ directory/file.cpp -o file –  Tomer Vromen Feb 18 '12 at 23:24
    
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 Feb 18 '12 at 23:40

2 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 this in the shell after navigating to the directory the file is in: ./a.out, and let me know what happens. As suggested by Tomer, if you remove the *.out extension is should open from the shell automatically I think.

share|improve this answer
    
if you would like to be able to open the file by double clicking on it, set it's default application to Terminal –  rubixibuc Feb 19 '12 at 2:09

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.