View Full Version : help with g++
spzentz
April 13th, 2007, 09:58 PM
Hi,
I have installed the package that includes g++. The compiler will compile c++ files but I cannot run the executable (in the terminal). It always says command not found.
Any help is apreciated.
Thanks
tino27
April 13th, 2007, 10:29 PM
This is probably due to the directory not being in your path. When in the same directory as the executable, try prefixing the name with "./". (without the quotes) to refer to the cwd.
WW
April 13th, 2007, 10:29 PM
Did you remember to put ./ in front of the executable?
Example: This is hello.cpp:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!\n";
return 0;
}
Compile and run:
$ g++ hello.cpp -o hello
$ ./hello
Hello, World!
$
spzentz
April 13th, 2007, 10:35 PM
Yes, I didn't realise that I needed the ./ before the executable.
Thanks for all the help.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.