LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Trouble running g++ compiled programs (https://www.linuxquestions.org/questions/linux-newbie-8/trouble-running-g-compiled-programs-465597/)

pxumsgdxpcvjm 07-19-2006 12:26 PM

Trouble running g++ compiled programs
 
I'm using Ubuntu 6.0.6 and I'm having trouble running compiled c++ programs that were compiled with g++. The compile process goes fine, no errors or anything. However, when I try to run my program from the command line, I get an "error: command not found" message.

ugenn 07-19-2006 12:30 PM

Prefix the command with "./"

lockpicker 07-19-2006 12:32 PM

please post the exact command strings you are using for compilation and running.

pxumsgdxpcvjm 07-19-2006 12:36 PM

I compile with this command:

g++ -o myprog myprog.cc

And I try to run it simply by typing:

myprog

Just to clarify, yes, I am in the current directory that the program file is in when i try to run it.

lockpicker 07-19-2006 12:40 PM

well then as stated, just use ./myprog instead of myprog!!

pxumsgdxpcvjm 07-19-2006 12:45 PM

I'm just curious as to why I need to append the './'? I'm used to programming in Red Hat but the system was all set up for me (school computer and all) and there all i had to do was type the program name with no './' to run it. Just a little FMI if possible.

bcfriesen 07-19-2006 01:09 PM

If you just type "myprog," the shell will search all the directories listed in your PATH environment variable for binaries called "myprog." My guess is that your school computer included your home folder in your PATH, but this machine does not, so your school computer would include your home folder in its search for a binary called "myprog," but the other computer doesn't.

Just a guess. I'm still a Linux noob ;-)

raskin 07-19-2006 01:11 PM

If you run a program, the system must be able to find it. If you specify path (for example, './') - it is no trick to find. But remembering which software is in /bin and which in /usr/bin is annoying. So if you don't specify path, system searches it in standard places. But current dir is not included in the list for some reasons, including tradition and some security (sudo-workalike downloaded by you in current dir should not get your password because you forgot about it). You can add it, though it is not recommended.


All times are GMT -5. The time now is 08:17 PM.