LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 04-03-2004, 02:36 AM   #1
mu664life
LQ Newbie
 
Registered: Dec 2003
Posts: 9

Rep: Reputation: 0
Unhappy a.out don't work


i just installed knopix 3.3 on my hard drive. and i try to write a simple c++ program in the Konsole by using vi editor. i named it hello.cpp, but when i compile it, and type a.out, it said bash: a.out: command not found!!

//this is the output what's on my screen:
knoppix@sharp:~/documents$ g++ hello.cpp
knoppix@sharp:~/documents$ a.out
bash: a.out: command not found
knoppix@sharp:~/documents$ g++ -o hello hello.cpp
knoppix@sharp:~/documents$ hello
bash: hello: command not found
knoppix@sharp:~/documents$

i try both g++ and g++ -o option and it didn't work....
it work before if i boot from the Knoppix cd.....but how come it doesn't work after i install it?

i'm really new at this....this is really my first time using linux.....so please forgive me if i ask some stupid questions.

thanks
 
Old 04-03-2004, 02:39 AM   #2
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
a.out do work
./a.out
 
Old 04-03-2004, 03:43 AM   #3
mu664life
LQ Newbie
 
Registered: Dec 2003
Posts: 9

Original Poster
Rep: Reputation: 0
thanx!!!!

i see how it works now.....

but why ./a.out???

i don't remember from other linux where i have to type the full path
 
Old 04-03-2004, 04:59 PM   #4
geekzen
Member
 
Registered: Mar 2004
Location: Canada. The Great white north.
Distribution: Debian Sid
Posts: 183

Rep: Reputation: 30
It is because its not in the path.
 
Old 12-14-2004, 06:43 PM   #5
hatchett
LQ Newbie
 
Registered: Dec 2004
Posts: 3

Rep: Reputation: 0
Hi,

maybe another stupid question, but I have a similar issue.

./a.out will work

but how to I then use gdb to debug a.out (I have compiled with -g option).

neither gdb a.out or gdb ./a.out get me very far,

thanks,

Jon
 
Old 12-14-2004, 07:06 PM   #6
zuralin
Member
 
Registered: Sep 2003
Distribution: Debian testing/unstable
Posts: 229

Rep: Reputation: 32
# man gdb

you will find what you need in there.
 
Old 12-14-2004, 07:49 PM   #7
hatchett
LQ Newbie
 
Registered: Dec 2004
Posts: 3

Rep: Reputation: 0
I'm sorry but I don't seem to be able to get it work. I have the current directory now in the $PATH variable, and a working program a.out, but I still have the following issue with gdb

GNU gdb Red Hat Linux (6.0post-0.20040223.17rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"..."/home/jonh/dynamicrewire/numerics/a.out": not in executable format: File format not recognized
 
Old 12-16-2004, 04:12 PM   #8
corfe
Member
 
Registered: Dec 2004
Location: Washington State, USA
Distribution: Debian Sid
Posts: 128

Rep: Reputation: 16
Hmm - that should work. I don't know why the format of a.out isn't recognized. You might want to try recompiling the file in case it's an error, or try it on another program (like /bin/ls). Make sure after you start the gdb program with the program name as the argument, you type in "run" at the gdb command prompt to see your program actually run!

Below, the teal is what you should be typing, the rest is roughly what you should see:

~$ gdb a.out
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-linux".
(gdb) run


======

As a side note, good UNIX's NEVER, EVER, EVER have the current folder as part of the path, this isn't just a slip on knoppix's part. This is for both historical reasons as well as security reasons - imagine if someone made their own "ls" program that did (insert something bad here), and root accidentally ran it when going to that user's profile directory and typing "ls" (to check the folder's contents - the "./" convention is to make it clear that you are intentionally running a program in THIS directory, and not one from /bin, or /usr/bin, or the like. It's not necessary when running gdb, because you're just sending it the file "a.out" as an argument, so it makes sense to check the current directory, in much the same way that "kword file.doc" would check the current directory for "file.doc".

So, I would leave the current path (which is denoted simply by a dot ".") out of the deal, and try to get used to the idea of "./programname"
 
Old 12-16-2004, 07:12 PM   #9
hatchett
LQ Newbie
 
Registered: Dec 2004
Posts: 3

Rep: Reputation: 0
The file a.out does work if I just run it from the shell. If I try to gdb /bin/ls I get:

bash-2.05b$ gdb /bin/ls
GNU gdb Red Hat Linux (6.0post-0.20040223.17rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"..."/bin/ls": not in executable format: File format not recognized

and for example if I try to run a.out from gdb then because the format is not recognized I get the message:

(gdb) run
Starting program:
No executable file specified.
Use the "file" or "exec-file" command.

Cheers
 
Old 12-20-2004, 03:44 PM   #10
corfe
Member
 
Registered: Dec 2004
Location: Washington State, USA
Distribution: Debian Sid
Posts: 128

Rep: Reputation: 16
Unhappy

Well, I'm pretty well stumped. I would try posting in some redhat forums, to see if maybe it's a bug with the gdb in your version of redhat. Also, try getting all the latest updates for gdb and all related packages, if any are available!

Good luck!
 
Old 12-21-2004, 08:24 AM   #11
acker
Member
 
Registered: Apr 2004
Location: Timisoara, Romania
Distribution: Debian
Posts: 90

Rep: Reputation: 15
To hatchett

I've seen you posted on gdb lists at gnu.
If you'll find the problem please let us (me) know. I've seen that someone said to you there that you should compile with the -g option. That is not quite correct for the error you are seeing.
I thought that it would be a problem with the a.out file but if you say that you get errors with /bin/ls than that's not good. You definetly should point the problems with /bin/ls to them.

--acker
 
  


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
Does the mounting of a *BSD partition on linux work work well when rw ? kloss *BSD 3 10-08-2005 02:21 PM
Will Ubuntu Work work With my Wireless Card? PulsarSL Ubuntu 3 10-07-2005 10:33 PM
got ALSA to work in root, need help getting it to work in my user profile ic3 Slackware 2 11-28-2003 10:32 PM
FALCONS EYE (nethack) FAILS ON STARTUP, use to work, wont work even after reinstall roorings Linux - Software 0 10-08-2003 10:39 PM
UPS cable didn't work. A cool work-around jlangelier LinuxQuestions.org Member Success Stories 1 07-18-2003 05:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 12:25 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