[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C++/STL linking trouble

On Wed, 2008-01-09 at 10:09 -0500, Adam C Powell IV wrote:
> On Wed, 2008-01-09 at 15:37 +0100, Thomas Girard wrote:
> > On Wed, Jan 09, 2008 at 07:07:30AM -0500, Adam C Powell IV wrote:
> > > I'm having trouble with a new C++ package called Salomé which I can't
> > > get to link to a C++ library in a new package OpenCASCADE.
> > > 
> > > Using nm -C I found that the library libTKernel has:
> > > 0000000000004c74 T operator<<(_STL::basic_ostream<char, _STL::char_traits<char> >&, TCollection_AsciiString const&)
> > > and the other missing symbols are in that and other OpenCASCADE libs
> > > with s/std/_STL/ .
> > > 
> > > >From Googling around, I've learned that this seems to be a confusion
> > > between the stlport namespace and standard C++ library namespace for the
> > > argument symbols.  So how do I either get Salomé to build in the stlport
> > > namespace, or get OpenCASCADE to not build there?
> > 
> > It seems the libTKernel has changed how STLport std:: namespace (through
> > _STDP_STD_NAME macro) gets expanded. If you have a look at libstlport5.1
> > symbols you should see there are defined in the stlp_std:: namespace.
> > Removing this #define _STDP_STD_NAME _STL from headers used by libTKernel
> > should fix the link failure.
> Thank you for pointing this out.  OpenCASCADE doesn't work with stlport
> 5.1, just 4.6.
> I don't see _STDP_STD_NAME in any of the OpenCASCADE headers...  Should
> I perhaps #define _STDP_STD_NAME std, or #undef it?

I think I found the problem.  I pre-processed two files in question,
TDF_Attribute.cxx in OpenCASCADE and testDS.cxx in Salomé.  I put both
outputs in http://lyre.mit.edu/~powell/salome/

In the former, /usr/include/stlport/stl/_iosfwd.h opens a "namespace
_STL {" then #includes /usr/include/stlport/stl/_iosfwd.h which has:
typedef basic_ostream<char, char_traits<char> > ostream; (line 2685)

In the latter, /usr/include/c++/4.2/iosfwd opens a
"namespace std __attribute__ ((__visibility__ ("default"))) {" then
#includes /usr/include/c++/4.2/iosfwd which has:
typedef basic_ostream<char> ostream; (line 6311)

So they lead to different symbols, which breaks linking.  What to do?

I see "using namespace std" in testDS.E (lines 31862 and 37777) and
"using namespace _STL" in TDF_Attribute.E (lines 17427 and 23430).
Would changing this in the OpenCASCADE headers override the "namespace
_STL {" and fix the problem?

Otherwise, how does a non-stlport binary link to an stlport library??

Thanks for any help and insights you can provide.

GPG fingerprint: D54D 1AEE B11C CE9B A02B  C5DD 526F 01E8 564E E4B6

Engineering consulting with open source tools

Reply to: