Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » bash: ./hello.o: cannot execute binary file: Exec format error(Hello world compile)
bash: ./hello.o: cannot execute binary file: Exec format error [message #1851796] Sat, 16 April 2022 04:33 Go to next message
stuart naylor is currently offline stuart naylorFriend
Messages: 2
Registered: April 2022
Junior Member
Hi total noob just trying a 1st compile and after a chmod a+x of the release build when I run in the release folder

bash: ./hello.o: cannot execute binary file: Exec format error

hello.o is just the name I used for the hello world template example I get the above error?

What am I doing wrong guys?
Re: bash: ./hello.o: cannot execute binary file: Exec format error [message #1851800 is a reply to message #1851796] Sat, 16 April 2022 12:19 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 739
Registered: August 2014
Senior Member
This is a bit off-topic for Eclipse, but I'll respond anyway:

The .o file is a relocatable symbolic binary file, and as such, not fit for being run. That is why it did not have the executable attribute.

The .o file needs to be processed by the linker (GNU ld) to combine it with the appropriate run-time libraries into a runnable file.

Try this:

gcc -o hello hello.o

It seems to me that you have translated the .c code with the -c option. Another way to get it right the first time is to translate:

gcc -o hello hello.c


--

Tauno Voipio
Re: bash: ./hello.o: cannot execute binary file: Exec format error [message #1851801 is a reply to message #1851800] Sat, 16 April 2022 12:53 Go to previous message
stuart naylor is currently offline stuart naylorFriend
Messages: 2
Registered: April 2022
Junior Member
Thanks Tauno,

Apologies as it was me being stupid I didn't give the c source an extension and made the presumption that was the c source files and not the compiled result.
Its starting to make sense and apols for my noobness.



[Updated on: Sat, 16 April 2022 13:04]

Report message to a moderator

Previous Topic:No such file or directory
Next Topic:Library Dependency Errors in Eclipse Version: 2021-09 (4.21.0) Build id: 20210910-1417
Goto Forum:
  


Current Time: Mon Jan 30 18:56:16 GMT 2023

Powered by FUDForum. Page generated in 0.04675 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top