ExtUtils-MakeMaker - libstdc++ problem with ExtUtils::MakeMaker

Posted on Thu Jul 20 18:51:15 2006 by sherlock
libstdc++ problem with ExtUtils::MakeMaker
Hi,

(I've posted this question elsewhere as well, so apologies if you're seeing this more than once).

The GO::TermFinder modules, which I wrote, often seem to have problems (platform dependent) when doing the make step, specifically compiling the swig code in the 'native' directory. The Makefile.PL in that directory has:

'LIBS' => ['-lm -lstdc++'],


but when the make is run, I see a complaint:

Note (probably harmless): No library found for -lstdc++


which later results in failures like:

# 'Can't load '/Users/sherlock/dev/GO-TermFinder/blib/arch/auto/GO/TermFinder/Native/Native.bundle' for module GO::TermFinder::Native: dlopen(/Users/sherlock/dev/GO-TermFinder/blib/arch/auto/GO/TermFinder/Native/Native.bundle , 2): Symbol not found: __ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base


during the make test phase. If however, I look at the generated Makefile in the native directory, I see:

LDLOADLIBS = -lm


if I change this to:

LDLOADLIBS = -lm -lstdc++


and redo the make, the problem is fixed. It is of course annoying to tell people they may need to hand edit make files during the installation process. Does anyone know what I'm doing wrong in the Makefile.PL file that might remedy the problem?

If I do:

perl -e 'require ExtUtils::Liblist; ExtUtils::Liblist->ext("-lstdc++", 1, 1);'


I get:

Potential libraries are '-lstdc++': stdc++ not found in /usr/local/lib stdc++ not found in /usr/lib Note (probably harmless): No library found for -lstdc++


poking around in /usr/lib, I see:

libstdc++-static.a libstdc++.6.0.3.dylib* libstdc++.6.0.4.dylib* libstdc++.6.dylib@ -> libstdc++.6.0.4.dylib


but this is where my ignorance prevents me from knowing if this is what I'm looking for. Poking around a little further, there is also:

/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/libstdc++.dylib


which probably is what I want, and the compiler seems to know how to find when given the -lstdc++ flag, but MakeMaker doesn't know how to find, so won't provide the flag (in fact this is a link to libstdc++.6.dylib back in the /usr/lib directory).

I also tried adding

'CC'=>'g++'


or

'PERLMAINCC'=>'g++'


to the Makefile.PL, but with the exact same results.

I also tried adding:

'LD'=>'g++'


which does seem to solve the problem, but I'm worried that this is not going to work across platforms - is there a better way to do this, without reinventing the wheel with some sniffing logic to determine their compiler? In this example, I was running Perl 5.8.8 on OSX 10.4.7, with ExtUtils::MakeMaker 6.17.

Many thanks in advance,

Gavin
Write a response