Boost C++ Libraries: Ticket #11671: explicit template instanciations in boost::serialization don't get exported with all compilers https://svn.boost.org/trac10/ticket/11671 <ul><li>Symptoms: </li></ul><p> my program (compiled with g++-4.2.1 on OS X 10.6) crashed at run-time with: </p> <pre class="wiki">dyld: lazy symbol binding failed: Symbol not found: __ZN5boost7archive21basic_text_oprimitiveISoED2Ev </pre><p> also reported (by someone else) at: h__ps://trac.macports.org/ticket/48717 </p> <ul><li>Diagnostic: </li></ul><p> not all compiler export the template instanciations when the template class is exported but not the template argument (in this case, std::ostream). </p> <p> g++-4.0 and g++-4.8 do, g++-4.2 and clang++-3.4 don't. </p> <pre class="wiki">$ g++-4.0 -dynamic -fPIC -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -I"." -c -o "basic_text_oprimitive.o" "libs/serialization/src/basic_text_oprimitive.cpp" &amp;&amp; nm -m basic_text_oprimitive.o|fgrep __ZN5boost7archive21basic_text_oprimitiveISoED2Ev 000003c2 (__TEXT,__text) external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev 00002d40 (__TEXT,__eh_frame) external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev.eh $ g++-4.2 -dynamic -fPIC -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -I"." -c -o "basic_text_oprimitive.o" "libs/serialization/src/basic_text_oprimitive.cpp" &amp;&amp; nm -m basic_text_oprimitive.o|fgrep __ZN5boost7archive21basic_text_oprimitiveISoED2Ev 000006d8 (__TEXT,__text) private external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev 00003bf8 (__TEXT,__eh_frame) private external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev.eh $ g++-mp-4.8 -dynamic -fPIC -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -I"." -c -o "basic_text_oprimitive.o" "libs/serialization/src/basic_text_oprimitive.cpp" &amp;&amp; nm -m basic_text_oprimitive.o|fgrep __ZN5boost7archive21basic_text_oprimitiveISoED2Ev000004dc (__TEXT,__text) external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev $ clang++-mp-3.4 -dynamic -fPIC -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -I"." -c -o "basic_text_oprimitive.o" "libs/serialization/src/basic_text_oprimitive.cpp" &amp;&amp; nm -m basic_text_oprimitive.o|fgrep __ZN5boost7archive21basic_text_oprimitiveISoED2Ev00000c70 (__TEXT,__textcoal_nt) weak private external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev 00003944 (__TEXT,__eh_frame) weak private external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev.eh </pre><ul><li>Related GCC bugs : </li></ul><p> h__ps://gcc.gnu.org/bugzilla/show_bug.cgi?id=17470 h__ps://gcc.gnu.org/bugzilla/show_bug.cgi?id=51930 </p> <ul><li>Solutions : <ul><li>adding <code>BOOST_SYMBOL_VISIBLE</code> (or the equivalent <code>#pragma GCC visibility</code>) to the template instantiation only solved the problem for clang-3.4. </li><li>adding <code>#pragma GCC visibility push(default)/#pragma GCC visibility pop</code> around <code>#include &lt;ostream&gt;</code> solved the problem for all compilers. </li></ul></li></ul><p> I do not know the side-effects of that second solution, but it seems like it is the only consistent one. All classes that are template arguments should be visible. </p> <p> Maybe other compilers have the same issue. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11671 Trac 1.4.3 frederic.devernay@… Sun, 20 Sep 2015 18:20:11 GMT <link>https://svn.boost.org/trac10/ticket/11671#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11671#comment:1</guid> <description> <p> patch at h__ps://raw.githubusercontent.com/MrKepzie/Natron/workshop/tools/MacOSX/ports/devel/boost/files/patch-serialization-visibility.diff </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 29 Sep 2015 20:57:48 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11671#comment:2 https://svn.boost.org/trac10/ticket/11671#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> I believe that all problems related to visibility have been addressed. I've checked the changes into develop branch. Please feel free to double check </p> Ticket