开发者

How to run g++ from a terminal window on my Mac

开发者 https://www.devze.com 2023-01-29 13:58 出处:网络
I have a simple C++ program that I can compile (g++ from command line) and run from my work-computer but not from my home-computer. I don\'t know how they differ! They 开发者_开发百科are both macbooks

I have a simple C++ program that I can compile (g++ from command line) and run from my work-computer but not from my home-computer. I don't know how they differ! They 开发者_开发百科are both macbooks and I have installed iPhone SDK on both.

On my home-computer: When I add /Developer/usr/bin to my PATH I can run g++ but it cannot include <string> and it does not recognize printf and such functions. What else do I need to do to make g++ work?


  1. Install xCode and then close
  2. Edit your c++ code file (I use Smultron, it is free and good)
  3. Save your file on Desktop with "cpp" termination
  4. Suppose you have test.cpp program
  5. Open Terminal (Applications -> Utilities)
  6. Change directory with command: cd Desktop
  7. Now write: g++ test.cpp -o test
  8. For run your program, in Terminal type: test (only that, without ending cpp!)
  9. If your program it is well writen, on the desktop appear a new file named test
  10. Click on it and you have your program running
  11. That is all!


When you installed Xcode and the iPhone SDK, did you check the box for Unix Development Support? I had a lot of problems with this sort of thing because I didn't do that, and the solution was to uninstall the SDK and start again with the box checked.

0

精彩评论

暂无评论...
验证码 换一张
取 消