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

  • 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

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.

  • 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
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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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