Boost C++ Libraries: Ticket #4670: Revised boost/config/compiler/gcc.hpp causes linker errors for Cygwin WIN32 apps https://svn.boost.org/trac10/ticket/4670 <p> A revision to boost/config/compiler/gcc.hpp makes the assumption that because Cygwin does not define a WIN32 macro, a WIN32 macro will never be defined when compiling applications for Cygwin. Win32 applications are supported under Cygwin, and the use of some third party libs (i.e. Agilent I/O Libraries) requires that a WIN32 macro be defined. This problem causes linker errors similar to the error below: </p> <p> scons: done reading SConscript files. scons: Building targets ... g++ -o test_serialization.o -c -g -Wall -ansi -mwin32 -mthreads -I/c/dvlp/boost_1_44_0 test_serialization.cpp g++ -o test_serialization.exe test_serialization.o -L/c/dvlp/boost_1_44_0/stage/lib -lboost_serialization -lboost_date_time -lboost_system Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL<span class="underline">N_116guid_initializerI7DerivedEEE12get_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL</span>N_116guid_initializerI7DerivedEEE20get_mutable_instanceEv: symbol not found collect2: ld returned 1 exit status scons: <strong>* [test_serialization.exe] Error 1 scons: building terminated because of errors. </strong></p> <p> A patch is attached that fixes this problem </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4670 Trac 1.4.3 cvclarke@… Tue, 21 Sep 2010 22:06:39 GMT attachment set https://svn.boost.org/trac10/ticket/4670 https://svn.boost.org/trac10/ticket/4670 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-config.patch</span> </li> </ul> <p> Patch for boost/config/compiler/gcc.hpp </p> Ticket cvclarkeiii@… Tue, 21 Sep 2010 22:08:17 GMT attachment set https://svn.boost.org/trac10/ticket/4670 https://svn.boost.org/trac10/ticket/4670 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">serialization_problem.zip</span> </li> </ul> <p> zip file containing a program that demonstrates the problem for Cygwin </p> Ticket John Maddock Wed, 22 Sep 2010 08:24:12 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4670#comment:1 https://svn.boost.org/trac10/ticket/4670#comment:1 <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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/65530" title="Fix for cygwin symbol visibility - sometimes _WIN32 may be defined ...">[65530]</a>) Fix for cygwin symbol visibility - sometimes _WIN32 may be defined even on cygwin. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4670" title="#4670: Bugs: Revised boost/config/compiler/gcc.hpp causes linker errors for Cygwin ... (closed: fixed)">#4670</a>. </p> Ticket setosha@… Wed, 29 Sep 2010 18:16:05 GMT <link>https://svn.boost.org/trac10/ticket/4670#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4670#comment:2</guid> <description> <p> I got same error on mingw from qt 4.7.0. Your fix </p> <p> boost 1.43 works fine... </p> <p> boost 1.44 with staticly linked boost_serialization </p> <pre class="wiki">Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_15binary_iarchiveEEEE12get_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_15binary_iarchiveEEEE12is_destroyedEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_15binary_iarchiveEEEE18get_const_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_15binary_iarchiveEEEE20get_mutable_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_15binary_oarchiveEEEE12get_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_15binary_oarchiveEEEE12is_destroyedEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_15binary_oarchiveEEEE18get_const_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_15binary_oarchiveEEEE20get_mutable_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_21naked_binary_iarchiveEEEE12get_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_21naked_binary_iarchiveEEEE12is_destroyedEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_21naked_binary_iarchiveEEEE18get_const_instanceEv: symbol not found Cannot export _ZN5boost13serialization9singletonINS_7archive6detail12_GLOBAL__N_13mapINS2_21naked_binary_iarchiveEEEE20get_mutable_instanceEv: symbol not found collect2: ld returned 1 exit status </pre> </description> <category>Ticket</category> </item> <item> <author>Anton Sergunov <setosha@…></author> <pubDate>Wed, 29 Sep 2010 18:32:31 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/4670#comment:3 https://svn.boost.org/trac10/ticket/4670#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">setosha@…</span> added </li> </ul> Ticket John Maddock Fri, 08 Oct 2010 09:24:02 GMT status, component changed; resolution deleted https://svn.boost.org/trac10/ticket/4670#comment:4 https://svn.boost.org/trac10/ticket/4670#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> <li><strong>component</strong> <span class="trac-field-old">config</span> → <span class="trac-field-new">serialization</span> </li> </ul> <p> I've tracked this down to a bug in the serialization library, so I'm reassigning the issue. </p> <p> Robert, here's the problem: When basic_iarchive.cpp is compiled the class "extened_type_info" is declared dllimport, as a result the linker is looking for the member functions of that class in a dll... except they're not present in an external dll, they're present in *this* dll and marked dllexport. </p> <p> Here's what gcc is doing here: dllexport just marks the symbol as visible, but doesn't change it's mangled name. dllimport changes the mangled name instructs the linker to create stub code for that symbol with the <span class="underline">imp</span> prefix that looks for the unmangled name in an external dll. Hense you can't mix import and export of the same symbol in the same dll. The same code compiles with msvc and gcc on linux due to chance really - they just happen to treat import and export as largely the same thing. </p> <p> In other words in the serialization sources - since each .cpp file appears in only one library, there should be just 2 source macros, lets say BOOST_SERIALIZATION_SOURCE and BOOST_WSERIALIZATION_SOURCE that control what gets built with import or export. BOOST_ARCHIVE_SOURCE can presumably be replaced by BOOST_SERIALIZATION_SOURCE and associated macros since all the archive sources are really just part of the narrow character serialization lib, and not a separate lib in their own right? Further these macros should be defined *before any serialization or archive headers are included*, otherwise you run the risk of inconsistent settings again. </p> <p> HTH, John. </p> Ticket John Maddock Fri, 08 Oct 2010 09:24:36 GMT owner, status changed https://svn.boost.org/trac10/ticket/4670#comment:5 https://svn.boost.org/trac10/ticket/4670#comment:5 <ul> <li><strong>owner</strong> changed from <span class="trac-author">John Maddock</span> to <span class="trac-author">Robert Ramey</span> </li> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> </ul> Ticket Robert Ramey Fri, 08 Oct 2010 16:18:15 GMT <link>https://svn.boost.org/trac10/ticket/4670#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4670#comment:6</guid> <description> <p> Thanks for the explanation. I realized that this was a problem when my msvc linker warned of the same symbols being exported and imported in the same group of modules. I hadn't figured out to resolve this so your suggestions are helpful. Unfortunately, I'm currently bogged down on some other stuff so I can't address it immediately. </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Wed, 20 Oct 2010 16:10:50 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4670#comment:7 https://svn.boost.org/trac10/ticket/4670#comment:7 <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've fixed this and checked the update into the trunk </p> Ticket