LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-19-2006, 12:26 PM   #1
pxumsgdxpcvjm
Member
 
Registered: Aug 2005
Posts: 235

Rep: Reputation: 30
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.
 
Old 07-19-2006, 12:30 PM   #2
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
Prefix the command with "./"
 
Old 07-19-2006, 12:32 PM   #3
lockpicker
Member
 
Registered: Feb 2006
Location: Sikkim Manipal Institute of Technology, Sikkim
Distribution: Slackware 10.2
Posts: 80

Rep: Reputation: 15
please post the exact command strings you are using for compilation and running.
 
Old 07-19-2006, 12:36 PM   #4
pxumsgdxpcvjm
Member
 
Registered: Aug 2005
Posts: 235

Original Poster
Rep: Reputation: 30
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.
 
Old 07-19-2006, 12:40 PM   #5
lockpicker
Member
 
Registered: Feb 2006
Location: Sikkim Manipal Institute of Technology, Sikkim
Distribution: Slackware 10.2
Posts: 80

Rep: Reputation: 15
well then as stated, just use ./myprog instead of myprog!!
 
Old 07-19-2006, 12:45 PM   #6
pxumsgdxpcvjm
Member
 
Registered: Aug 2005
Posts: 235

Original Poster
Rep: Reputation: 30
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.
 
Old 07-19-2006, 01:09 PM   #7
bcfriesen
LQ Newbie
 
Registered: Nov 2005
Distribution: Ubuntu 7.10
Posts: 16

Rep: Reputation: 0
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 ;-)
 
Old 07-19-2006, 01:11 PM   #8
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove compiled programs? piggysmile Linux - Software 2 03-22-2005 05:25 AM
running compiled c++ programs in Fedora klmbrt Linux - Newbie 2 03-02-2005 09:54 AM
Running programs compiled under RH9 Pazabo Fedora 2 08-30-2004 09:54 AM
why ./ is used to run C++ compiled programs legend1079 Red Hat 4 03-23-2004 06:32 AM
cannot run C compiled programs Astro Slackware 7 01-27-2004 10:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration