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?
- Install xCode and then close
- Edit your c++ code file (I use Smultron, it is free and good)
- Save your file on Desktop with "cpp" termination
- Suppose you have test.cpp program
- Open Terminal (Applications -> Utilities)
- Change directory with command: cd Desktop
- Now write: g++ test.cpp -o test
- For run your program, in Terminal type: test (only that, without ending cpp!)
- If your program it is well writen, on the desktop appear a new file named test
- Click on it and you have your program running
- 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.
精彩评论