LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva
User Name
Password
Mandriva This Forum is for the discussion of Mandriva (Mandrake) Linux.

Notices



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

Rep: Reputation: 0
Mendrake9.2, bash: cannot execute binary file


I wrote a simple c++ programme. when I try to execute it, the bash shell complain 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-20-2004, 05:53 AM   #2
Quartz
LQ Newbie
 
Registered: Jan 2004
Location: Grenoble - France
Posts: 7

Rep: Reputation: 0
Are you sure the compilation is correct and generate an executable file ?
With ldd you can check linker information.

Yves
 
Old 01-20-2004, 09:10 AM   #3
premier_la
LQ Newbie
 
Registered: Jan 2004
Location: Germany
Posts: 9

Original Poster
Rep: Reputation: 0
I tried, this is what I get :

$ld -s -lc /usr/lib/crt1.o test.o
/usr/lib/crt1.o(.text+0xc): In function `_start':
../sysdeps/i386/elf/start.S:92: undefined reference to `__libc_csu_fini'
/usr/lib/crt1.o(.text+0x11):../sysdeps/i386/elf/start.S:93: undefined reference to `__libc_csu_init'

$ld -s -lc /usr/lib/crtn.o test.o
ld: warning: cannot find entry symbol _start; defaulting to 00000000080481a8
 
Old 01-21-2004, 01:45 PM   #4
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
 
Old 01-22-2004, 06:16 PM   #5
magicvash
Member
 
Registered: Aug 2003
Location: Chicago
Distribution: Mandrake 9.1 (x86)
Posts: 62

Rep: Reputation: 15
i'm not sure you're understanding g++ correctly.

g++ test.cpp

this says "compile test.cpp, and link the object file(s) together into an executeable called a.out"

g++ -o test -c test.cpp

this says "compile the file test.cpp into an object file and name that object file test"


what you want is

g++ -o test test.cpp

this says "compile the file test.cpp into an object file and link the object files together to form an executable named test"
 
  


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 03:39 PM
Cannot Execute Binary File meshcurrent Linux - Software 3 07-09-2005 04:39 PM
Mandrake9.2, bash: /cannot execute binary file premier_la Linux - Software 10 01-23-2004 03:53 AM
cannot execute binary file azpeitia Red Hat 2 12-17-2003 01:09 AM
bash: /bin/cat: cannot execute binary file inTUXicated Linux - General 9 08-06-2003 08:56 AM


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