Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost symbol not found

I'm trying to compile/port an older version of OpenOffice. It uses Boost v1.34.1, which is part of the source tree. The error message is as follows:

Undefined symbols:
  "boost::throw_exception(std::exception const&)", referenced from:
      boost::detail::shared_count::shared_count<ScToken>(ScToken*)in detfunc.o
ld: symbol(s) not found

Boost is new to me, and I haven't been able to find much online to help me understand this. From the error message, I understand that I probably need to link a library. However, boost::throw_exception is defined in a header file with no matching library (that I can find). Just for kicks, I've tried #include <boost/throw_exception.hpp> in detfunc and using symbolic links to put the header file in the same directory with no luck.

Is there a library I should be linking with -l or an include path with -I? How should I get that symbol referenced in?

like image 538
Jerry Avatar asked Feb 14 '12 06:02

Jerry


1 Answers

Boost expects the project either to be built with macro BOOST_NO_EXCEPTIONS undefined, or to define the function boost::throw_exception itself.

From <boost/throw_exception.hpp> in version 1.34.1:

namespace boost
{

#ifdef BOOST_NO_EXCEPTIONS

void throw_exception(std::exception const & e); // user defined

#else

//[Not user defined --Dynguss]
template<class E> inline void throw_exception(E const & e)  
{
    throw e;
}

#endif

} // namespace boost

Boost's configuration headers will determine whether to define the macro or not. It looks like it boils down to the compiler you're using, but there may be other factors. Take a look in the boost/config/compiler/ folder for the header file that corresponds to your compiler, then search for BOOST_NO_EXCEPTIONS in it. There should be some conditions around the #define to help explain when Boost defines it. You may be able to configure your build to avoid the definition and get past the linker error you're experiencing.

If you're unable to change your compiler config to avoid the definition, then you're probably left defining boost::throw_exception(std::exception const & e) yourself somewhere in the OpenOffice code. I'm unfamiliar with that code, though, so I can't give a good suggestion where it should go.

like image 81
user1201210 Avatar answered Nov 11 '22 17:11

user1201210