views:

1551

answers:

5

After upgraded to Snow Leopard, I can no longer run Eclipse CDT project on my computer. While the build process completes without any error, Eclipse does not recognize the binary file it created. When try to point to the binary file in Run Configuration.. dialog, it cannot find any binary in the project. Though executing the file from Terminal works fine.

According to a post at on Eclipse forum, this might be a problem that Mach-O parser does not recognize 64-bit binaries. Does anyone know what are the solutions or workarounds to the problem so that I can run/debug my C++ projects on Snow Leopard.

UPDATED

The solution suggested by Shane, though allowing the binary created to be recognized, does introduce another problem. Since system libraries in Snow Leopard are all 64 bits, it is no longer possible to link the code created with -arch i386 with these libraries, and hence not a feasible solution yet.

+2  A: 

Hi,

As per the post you referenced, you need to add -arch i386 to the compiler and linker settings for the project. Then when you rebuild the project, CDT picks up the executibles.

Project Properties -> C/C++ Build -> Settings. Then in compiler and linker Miscellaneous sections add the flag in Other flags.

Cheers,

The suggestion does the trick. Previously, I added -arch i386 flag to the compiler only without realizing that the linker also plays the part too.
ejel
Sorry for previously accepted the answer and taken it back. I realized that the solution does not actually work due to linking problem with system libraries which are 64 bits. See my updated question.
ejel
+1  A: 

gmatt,

The 64 binaries are different as the new architecture has new general purpose registers as well. There are also more differences in the architectures that would affect the opcodes you will see in the binary.

Cheers, Shane

Shane
+2  A: 

As Eclipse's binary parser has not been updated to recognized the new 64-bit Mach-O binary format (https://bugs.eclipse.org/bugs/show_bug.cgi?id=270790), it looks like the only workaround now is to compile code in 32-bit mode.

The consequence is that it is not possible to link C/C++ project to any system libraries since most of them are compiled as 64-bit already.

My solution for now is temporary switching to XCode.

ejel
You can now find a patch that fix this problem in the above link.
ejel
A: 

Is there any way to set this globally so that each project created has the "-arch i386" flag for the compiler and linker?

MikeD
+1  A: 

A new Mach 64 bit binary parser has finally been released.

I just did an update in Eclipse and under project properties selected the new binary parser. I can finally run my c++ binaries from within Eclipse, but I am still struggling with debugging for some reason.

Sveinn