g++: command not found

Jan 30, 2014 at 7:29pm
Hi. I am getting started with Unix programming, but I am having difficulty compiling my programs. I have .cpp files, which I try to use the g++ command on. However, the terminal responds "-bash: g++: command not found". I have read online that it might mean that I do not have the g++ compiler installed on my computer, but I am using my university's server, with which we have been instructed to use g++ to compile our code. Can somebody tell me what I need to do here to get these programs to compile? Thanks.



Roberts-MacBook-Pro-2:~ drinkibird$ cat hello.cpp
#include

int main()
{
cout << ("Hello World! From C++.\n");
return 0;
}

Roberts-MacBook-Pro-2:~ drinkibird$ g++ hello.cpp
-bash: g++: command not found
Roberts-MacBook-Pro-2:~ drinkibird$ g++ baz.cpp
-bash: g++: command not found
Roberts-MacBook-Pro-2:~ drinkibird$ g++ hello.cpp -o hello
-bash: g++: command not found
Roberts-MacBook-Pro-2:~ drinkibird$ g++ baz.cpp -o baz
-bash: g++: command not found
Roberts-MacBook-Pro-2:~ drinkibird$
Jan 30, 2014 at 7:46pm
It means you probably haven't installed the tools for it. I don't know what you have to do to install the tools needed in Macs though.

Does gcc -v output anything in the terminal? If the tools are installed it will print out version information. If it isn't installed it will tell you again command not found.
Last edited on Jan 30, 2014 at 7:51pm
Jan 30, 2014 at 8:30pm
> I am using my university's server, with which we have been instructed to use g++ to compile our code.
> Can somebody tell me what I need to do here to get these programs to compile?

Ask your university's sysadmin to install 'Command line tools for Xcode' on the server.
Jan 30, 2014 at 10:27pm
If he is connecting to the uni server they shouldn't have to install tools for his OS. It should be using g++ on the uni server to compile it. I'm assuming they are having them tunnel to it so he should be able to use the tools on their server.
Jan 31, 2014 at 8:37am
> If he is connecting to the uni server they shouldn't have to install tools for his OS.

If ldelsignore has to connect to the university server, and compile code on the server using g++, the GNU toolchain has to be installed on the server. It is not needed on the local machine.

If ldelsignore has to compile code on the local machine using GCC, the GNU toolchain has to be installed on the local machine. A connection to the server is not required at all.


> I'm assuming they are having them tunnel to it

Most likely, they expect students to login remotely with ssh.
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ssh.1.html

Jan 31, 2014 at 9:53am
Roberts-MacBook-Pro-2:~ drinkibird$ 

Looks like local machines prompt.

OS X does not have development tools installed by default. One has to get them from Apple. There are both big GUI thingy packages and the Command Line utilities. The latter is enough.
Topic archived. No new replies allowed.