A Conversation for How do I...?
..run a c++ program on my osx terminal?
Researcher207975 Started conversation Apr 18, 2003
I'm trying to learn the basics of c++ programming using the terminal on my mac (wanna learn it this way before I get into Project Builder), but I'm getting a bit
I've managed to compile my program using the "c++ hello.cpp -o hello" command, which created a file called hello for me (I was thinking that this was my executable file).
If I type "hello" in, I just get a "hello: command not found" error.
I've also tried compiling it using "c++ hello.cpp" which gave me a a.out file, which also gave me a similar message when I tried to run it.
Could someone please give me a hand?
..run a c++ program on my osx terminal?
Is mise Duncan Posted Apr 18, 2003
It's a long long time since I did this from the command line but if I recall corectly compiling just gives you the symbolic object files and you need to link these using the linker (which as link hello.obj -o hello.exe?) command to make an executable.
..run a c++ program on my osx terminal?
Researcher207975 Posted Apr 18, 2003
Bugger!
I just tried: link hello.obj -o hello.exe
...and got the same old same old, except this time it couldn't find the 'link' command.
The silly thing is, I got the 'Complete Idiot's Guide' book, which I thought would tell me how to do everything assuming I know nothing... unfortunately, the very first exercise has a bit of code for you to copy out followed by the instructions, 'Save it, Compile it, Build it, Run it' without explaining how.
..run a c++ program on my osx terminal?
Phil Posted Apr 23, 2003
As osX is based on Unix you'll need to make sure that the directory that has the executable (hello or a.out) is in your path - that is where the os looks to find executable programs.
You could try the command printenv to see what the environment variables are. The one you're looking for is called PATH.
You could also try running the hello command as ./hello
These are tips from a unix perspective rather than a mac as I've used one but not really used the other.
Hope this helps.
Key: Complain about this post
..run a c++ program on my osx terminal?
More Conversations for How do I...?
Write an Entry
"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."