Skip navigation

As I understand the issue, there can be multiple causes for this error (not building against the correct machine architecture, permissions set incorrectly, etc.) but for me none of these common issues solved the problem.  I was in a bit of a unique situation you see– I had built an application as a static library to be utilized by a different application, and I wanted to return to development of the original application.  This required rolling its settings back to build as an executable rather than a static library.  I did this by changing the artifact extension from static library (.a) to executable, but I noticed the executable icon in eclipse was still a ‘plugin symbol’ (jigsaw puzzle piece) rather than a ‘go symbol’ (circle with an inscribed arrow pointing right).  After much googling to little effect and executing the program from the terminal to verify that it produced the same error [cannot execute binary file and ‘echo $?’ to see the last exit code yields 126], I took another look at the command string eclipse was generating and saw the odd switch ‘-dynamiclib’ appended after the various ‘-framework x’ linker switches I needed.  Looking deeper into my linker settings I noticed that the ‘Shared’ box was checked under ‘Shared Library Settings’. The solution of course was to uncheck this box, which removed -dynamiclib from the command string.

In sum, the missing step was as follows:

1. Go to project->properties->C/C++ Build->Settings->MacOS X C++ Linker->Shared Library Settings and uncheck the ‘Shared (-dynamiclib)’ box.  I don’t know why that was checked to begin with since I was building static libs before, but whatever the case this fixed the problem and made the program fully executable again.

Advertisements

One Comment

  1. Thank you so much for this! I was about to give up on trying to develop C++ on OS X. This completely solved the issue for me.


One Trackback/Pingback

  1. By C++ in Eclipse on OS X 10.8 with OpenGL on 05 Apr 2013 at 2:00 am

    […] 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 […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: