help with g++-mp-4.5

Ryan Schmidt ryandesign at macports.org
Tue Jun 7 02:41:26 PDT 2011


On Jun 7, 2011, at 01:16, Titus von Boxberg wrote:

> The same problem is given here:
> http://stackoverflow.com/questions/4697859/mac-os-x-and-static-boost-libs-stdstring-fail
> 
> But I currently do not understand the problem.
> And the "solution" given there as far as I get it would mean that
> macport's c++ libraries are useless in conjunction with mp-g++?

Reading that Stack Overflow post, it says that the reason their program compiled with gcc 4.5 doesn't work is that the boost library they're trying to statically link with was built with gcc 4.2. The solution was to either build their program with gcc 4.2 too, or to build boost with gcc 4.5 too. It's best to compile all parts of your project with the same compiler to avoid these types of problems. The article says the problem may also only appear when linking to static libraries, so link to the dynamic library instead. On Mac OS X, dynamic linking is preferred to static linking anyway; possibly this problem is one of the reasons for that recommendation.

In your case, you're trying to link with cppunit, not boost, but other than that it seems similar. Except that the compile command you've shown doesn't seem to be specifically requesting to link with the static library. I thought dynamic linking was the default when both are available (which they are for cppunit). Maybe you need to explicitly request the dynamic library.

MacPorts does not provide users with a means of specifying what compiler they want to use; instead it's up to the port maintainers to choose the correct compiler or provide compiler options. And unless there is a good reason why it won't work, most ports will use the default compiler, which on Snow Leopard is Apple's build of gcc 4.2. Assuming you require gcc 4.5 and 4.2 is not sufficient, you could try to override it when installing cppunit (sudo port install cppunit configure.cc=macports-gcc-4.5) but I don't know whether this will work on cppunit, and it's certainly not something we will support. You could also build cppunit manually with gcc 4.5. 






More information about the macports-dev mailing list