the Life of Zim

5th April
written by dzimney

So for the past couple of days I’ve been trying to get a Hello, World! program to run using C++ in Eclipse Juno on my MacBook Pro running OS X 10.8.3. After getting the project to build in Eclipse and getting a successful compile, I kept getting the following error when running the executable: “cannot execute binary file”. The binary file also was being shown in the Project Explorer in Eclipse with a puzzle piece icon, rather than the executable “play” icon. As it turns out, by default Eclipse will set up the project to generate a shared Library rather than an executable, or so it seems. To fix the issue, go into the project properties and under MacOS X C++ Linker, uncheck Shared (-dynamiclib) in the Shared Library Settings sub section. Apply the changes, run a build and presto!

This solution is all thanks to this post. I’m just reposting the solution to firstly help remind myself of what to do and secondly in hopes that the reposting will help someone else find the solution faster than I did.

As far as I can tell, OpenGL had little to do with the problem, but since I noticed the problem after trying to run an OpenGL project, I thought it valuable to tag it.