LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Executable problems (https://www.linuxquestions.org/questions/linux-newbie-8/executable-problems-207885/)

chansen0421 07-21-2004 10:31 AM

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.

michaelk 07-21-2004 10:40 AM

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

rylan76 07-21-2004 11:02 AM

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!


All times are GMT -5. The time now is 04:08 AM.