LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-31-2008, 11:45 PM   #1
Pengye
LQ Newbie
 
Registered: May 2008
Posts: 9

Rep: Reputation: 0
bash: command not found


Hi,

I'm trying to compile and run a simple c++ program in the command line.
But after the compilation, bash replies "command not found" when I try to run the program.

g++ -o sim_pro sim_pro.cpp
sim_pro
bash: sim_pro: command not found

PLZ help me!!!
 
Old 05-31-2008, 11:52 PM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You need to run the executable as "./sim_pro". This tells the shell to run the executable in the current directory (which is what . is shorthand for). When you specify an executable, the shell looks in the directories listed in $PATH for it, so that's why you get "command not found" (because it isn't in one of those directories).
 
Old 05-31-2008, 11:53 PM   #3
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
Unless sim_pro is in a directory that is in your $PATH, you need to provide either the absolute or relative path to the executable. Try executing sim_pro like
Code:
./sim_pro
 
Old 05-31-2008, 11:57 PM   #4
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

Do you have g++ aliased (Wondering if there's an odd character in there)


Also, have you tried changing your shell and running this. If ksh gives you the same error, try using -Wall in your compile options so that, if it's really g++ complaining, it'll let you know.

Best wishes,

Mike
 
Old 06-01-2008, 10:21 AM   #5
Pengye
LQ Newbie
 
Registered: May 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Hi,

The problem is solved. I try calling ./sim_proc, and it works. Thanks very much!

Henry
 
Old 06-01-2008, 11:57 PM   #6
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Good show and embarassment on my end

I thought the g++ compile was giving the error, not the compiled executable... Ignore all the wasted space I added to this thread earlier

, Mike
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash command not found Legolas327 Linux - Newbie 9 06-27-2007 07:44 PM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
bash: command not found intels_ss Linux - Newbie 5 07-20-2005 07:41 PM
bash: pg: command not found Chomper Programming 2 02-05-2005 02:22 AM
-bash: ls: command not found jchun Linux - General 3 11-02-2004 10:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:19 PM.

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