LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-21-2004, 11:31 AM   #1
chansen0421
LQ Newbie
 
Registered: Jul 2004
Location: Utah
Distribution: openSUSE 11
Posts: 13

Rep: Reputation: 0
Question Executable problems


I just installed Fedora 2 Linux. I had some trouble at first with the GRUB, But it is up and working now.
I am a student and am new at using Linux
I tryed to compile a simple "hello world" c++ program using g++, and when I tried to run it by typing the default a.out it didn't run, but gave me an error message, something like, "not a valid command".
any help would be nice.
 
Old 07-21-2004, 11:40 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,936

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
I'm guessing the error was "command not found".

linux only searches using the path environment and not the current working directory. The shortcut for current working directory is ./

To execute your program use:
./a.out

You can add current working to your path environment but I do not recommend it for a newbie
 
Old 07-21-2004, 12:02 PM   #3
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,487

Rep: Reputation: 88
Hi

Try this when compiling

g++ -o programname programname.cpp

This will output to programname the executable file.

You can then run this with

./programname

in a terminal/xterm/terminal emulator.

BTW if you find typing ./ to access files int he current directory, simply add this to the .bashrc file (if you use bash) that gets executed when you start an xterm:

PATH=$PATH:$HOME/:./:

To add more stuff to your path simply put more entries between colons:

PATH=$PATH:$HOME/:./:./bin:/usr/java/j2re1.4

is a small sample of my path.

After closing and restarting the xterm with this bashrc, you should be able to run programs in the current directory without having to type ./ before all of them.

Thanks for choosing Linux!
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 05:57 AM
executable programs petezilla Linux - Newbie 6 04-13-2005 07:36 PM
running an executable wogga Linux - Software 8 06-12-2004 05:21 AM
problems compiling executable with gcj wslyhbb Programming 0 12-19-2003 10:48 AM
Autostart for an Executable Raygun Linux - General 3 05-14-2001 07:28 AM


All times are GMT -5. The time now is 10:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration