Boost logo

Boost Users :

Subject: [Boost-users] Using boost with explicit template instance
From: ranadheer p (p_ranadheer_at_[hidden])
Date: 2011-10-10 22:24:00


We have built a C++ library using Boost and when we try to integrate the library in a binary we are having problem in linking because of “--instances=explicit” option used for building the binary. The problem is, when we use --instances=explicit option (of Sun CC compiler) it expects us to instantiate the templates explicitly. As Boost internally uses templates when we use Boost with this option the linker is throwing “Undefined symbol” errors - which is expected as we are not instantiating the templates used in Boost explicitly. Though I understand why the linker is throwing the error here, it looks tricky to instantiate all boost templates explicitly in the code. So, want to check if there any solution/workaround to use Boost with “-instances=explicit” option of Sun CC compiler. Any help is much appreciated. We can reproduce the problem with simple sample code as - #include<iostream> #include<boost/lexical_cast.hpp> intmain() {     std::cout<<boost::lexical_cast<int>(“8”)<<std::endl; } With “--instances=explicit” option Undefined                      first referenced symbol                             in file __type_0 boost::detail::lexical_cast<unsigned,std::string,false,char>(__type_0,__type_3*,unsigned)    lexical.o ld:fatal:Symbolreferencing errors.Nooutput written to a.outWithout “--instances=explicit” option this works fine



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net