LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-19-2004, 05:40 PM   #1
premier_la
LQ Newbie
 
Registered: Jan 2004
Location: Germany
Posts: 9

Rep: Reputation: 0
Question Mandrake9.2, bash: /cannot execute binary file


I wrote a simple c++ programme. when I try to execute it, the bash shell complains that it "cannot execute binary file."

Any idea why this error ?

I have set chmod 777 to the executable, but the same problem.

Thanks,
Premier_la
 
Old 01-19-2004, 06:40 PM   #2
Kurt M. Weber
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 335

Rep: Reputation: 36
Have you compiled it?
 
Old 01-20-2004, 04:18 AM   #3
premier_la
LQ Newbie
 
Registered: Jan 2004
Location: Germany
Posts: 9

Original Poster
Rep: Reputation: 0
yes, I have compiled

$ cc -o test -c test.cpp
$ ./test
gives
$ bash: ./test: cannot execute binary file
 
Old 01-20-2004, 05:07 AM   #4
yuray
Member
 
Registered: Apr 2003
Location: Russia, Khotkovo
Distribution: Debian
Posts: 146

Rep: Reputation: 15
What type of filesystem you using ?
Check what you partition (where test relies) have permission on executing binaries.
Type command "mount".
 
Old 01-20-2004, 05:39 AM   #5
premier_la
LQ Newbie
 
Registered: Jan 2004
Location: Germany
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks Yuray,

I typed the mount command & it gives the following output.


/dev/ide/host0/bus0/target0/lun0/part6 on / type ext3 (rw)
none on /proc type proc (rw)
none on /proc/bus/usb type usbfs (rw)
none on /dev type devfs (rw)
none on /dev/pts type devpts (rw,mode=0620)
/dev/ide/host0/bus0/target0/lun0/part8 on /home type ext3 (rw)
none on /mnt/cdrom type supermount (ro,dev=/dev/hdb,fs=udf:iso9660,--,iocharset=iso8859-1)
none on /mnt/cdrom2 type supermount (ro,dev=/dev/scd0,fs=udf:iso9660,--,iocharset=iso8859-1)
none on /mnt/floppy type supermount (rw,sync,dev=/dev/fd0,fs=ext2:vfat,--,codepage=850,umask=0,iocharset=iso8859-1)
/dev/ide/host0/bus0/target0/lun0/part1 on /mnt/win_c type ntfs (ro,umask=0,iocharset=iso8859-1)
/dev/ide/host0/bus0/target0/lun0/part5 on /mnt/win_d type ntfs (ro,umask=0,iocharset=iso8859-1)

I don't understand the exact details of the output, but as u refered, to see the perrmission for the partition type .... it seems to me that it has (/dev/ide/host0/bus0/target0/lun0/part6 on / type ext3 (rw)) read write permission only.
How to make it executable?
 
Old 01-21-2004, 05:26 AM   #6
yuray
Member
 
Registered: Apr 2003
Location: Russia, Khotkovo
Distribution: Debian
Posts: 146

Rep: Reputation: 15
(rw) Its OK.
Where are you compling test ?
Type command "pwd" in dir where you start $ cc ....
 
Old 01-21-2004, 07:32 AM   #7
premier_la
LQ Newbie
 
Registered: Jan 2004
Location: Germany
Posts: 9

Original Poster
Rep: Reputation: 0
I'm compiling it from my home directory.

$/home/premier
the .cpp file is in premier dir.

Last edited by premier_la; 01-21-2004 at 12:33 PM.
 
Old 01-21-2004, 12:34 PM   #8
premier_la
LQ Newbie
 
Registered: Jan 2004
Location: Germany
Posts: 9

Original Poster
Rep: Reputation: 0
I got it executed this way:
I tried $g++ test.cpp
which produce a.out & it executes properly.

But when I try this way
$g++ -o test -c test.cpp does not work

also $cc .... does not work ??
Is there any configuration to be done in .bash_profile ??
Thanks

Last edited by premier_la; 01-21-2004 at 12:46 PM.
 
Old 01-22-2004, 02:11 AM   #9
yuray
Member
 
Registered: Apr 2003
Location: Russia, Khotkovo
Distribution: Debian
Posts: 146

Rep: Reputation: 15
It is very strange.
Try
$ cc -o test -static -c test.cpp
 
Old 01-22-2004, 04:37 PM   #10
premier_la
LQ Newbie
 
Registered: Jan 2004
Location: Germany
Posts: 9

Original Poster
Rep: Reputation: 0
This works fine
$ g++ -o test test.cpp (without -c option)

but
$ g++ -o test -c test.cpp ,
produce executable, but again the same, bash: ./test: cannot execute binary file.

$ g++ -o test -static -c test.cpp
/usr7/bin/ld: cannot find -lstdc++

$ cc... same dont work.
 
Old 01-23-2004, 02:53 AM   #11
yuray
Member
 
Registered: Apr 2003
Location: Russia, Khotkovo
Distribution: Debian
Posts: 146

Rep: Reputation: 15
Aaa.
-c option produce object file. This file can not be executed.
This file must be _linked_ (ld command ) with startup object files and result will be executed.
 
  


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
bash: ./runcbl: cannot execute binary file message Earla Harding Linux - Enterprise 0 07-27-2005 02:39 PM
cannot execute binary file Quest101 Linux From Scratch 8 11-19-2004 01:16 PM
Mendrake9.2, bash: cannot execute binary file premier_la Mandriva 4 01-22-2004 05:16 PM
Cannot execute binary file pbagda Linux - General 4 01-19-2004 01:13 AM
bash: /bin/cat: cannot execute binary file inTUXicated Linux - General 9 08-06-2003 07:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04: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
Open Source Consulting | Domain Registration