Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-16-2005, 08:21 PM   #1
LQ Newbie
Registered: Feb 2005
Posts: 29

Rep: Reputation: 15
compiling c++ question

my question is very simple (i hope). I write a program in c++ and compile it with g++ using the command line options "g++ -ansi -Wall test.cpp -o test" now how is it that after I compile without errors the darn thing won't run the program by typing "test" it does nothing. I am asking this because I do the same procedure at my colleges computers and the program executes and I can see output if I made it display output. I am just confused since I have fedora core 3 newest kernal and the college uses redhat 9 with older kernal and g++ version/libraries...
Old 02-16-2005, 08:38 PM   #2
Mega Man X
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Try running with "./test" instead of "test". I guess that your test is an executable program, but not executable (sounds dumb, I know... but in Linux, to make a file an executable, you've to use the command "chmod +x file_name" in order to make it executable).

Well, worth a shot I guess
Old 02-16-2005, 09:13 PM   #3
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
It's just a bad choice for an executable name. There is already a "test" program installed on your machine.

Change the g++ command to create an executable of a different name. Something like:
g++ -ansi -Wall -o test1 test.cpp
The reason your college computer doesn't behave this way is probably a difference on how the PATH environment variable is set up.

If you get a "command not found" error when you try to run the executable using the new name, then you'll need to preface it with a ./ like Megaman X mentioned:
The ./ is required if your working directory is not listed in your PATH.

Last edited by Dark_Helmet; 02-16-2005 at 09:21 PM.
Old 02-17-2005, 06:12 AM   #4
LQ Newbie
Registered: Feb 2005
Posts: 29

Original Poster
Rep: Reputation: 15
actually that helped a lot, i was only using test in the example but actually my program was called reverse and i was getting command not found and i was a bit puzzled, thanks again


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
compiling question noxious Slackware 11 09-29-2004 04:34 PM
compiling question phil81 Linux - Software 5 06-02-2004 08:46 AM
g++ Compiling Question ErikJohnson Linux - General 9 04-01-2004 07:48 AM
compiling question glo Linux - Newbie 0 07-28-2003 10:50 AM
Compiling Question fotoguy Linux - Software 0 05-24-2003 04:41 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:33 AM.

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