Boost C++ Libraries: Ticket #3435: Linking failure with MSVC 7.1 https://svn.boost.org/trac10/ticket/3435 <p> While trying to build Boost.Test 1.40 into a shared library with MSVC 7.1 I encountered the following linking errors: </p> <pre class="wiki">boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::results_collector_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::results_collector_t&gt;::instance(void)'::`2'::$S11" (?$S11@?1??instance@?$singleton@Vresults_collector_t@unit_test@boost@@@unit_test@boost@@SAAAVresults_collector_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::unit_test_monitor_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::unit_test_monitor_t&gt;::instance(void)'::`2'::$S11" (?$S11@?1??instance@?$singleton@Vunit_test_monitor_t@unit_test@boost@@@unit_test@boost@@SAAAVunit_test_monitor_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::results_collector_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::results_collector_t&gt;::instance(void)'::`2'::$S13" (?$S13@?1??instance@?$singleton@Vresults_collector_t@unit_test@boost@@@unit_test@boost@@SAAAVresults_collector_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::unit_test_log_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::unit_test_log_t&gt;::instance(void)'::`2'::$S13" (?$S13@?1??instance@?$singleton@Vunit_test_log_t@unit_test@boost@@@unit_test@boost@@SAAAVunit_test_log_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::unit_test_log_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::unit_test_log_t&gt;::instance(void)'::`2'::$S14" (?$S14@?1??instance@?$singleton@Vunit_test_log_t@unit_test@boost@@@unit_test@boost@@SAAAVunit_test_log_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::results_collector_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::results_collector_t&gt;::instance(void)'::`2'::$S26" (?$S26@?1??instance@?$singleton@Vresults_collector_t@unit_test@boost@@@unit_test@boost@@SAAAVresults_collector_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::unit_test_log_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::unit_test_log_t&gt;::instance(void)'::`2'::$S30" (?$S30@?1??instance@?$singleton@Vunit_test_log_t@unit_test@boost@@@unit_test@boost@@SAAAVunit_test_log_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::results_collector_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::results_collector_t&gt;::instance(void)'::`2'::$S3" (?$S3@?1??instance@?$singleton@Vresults_collector_t@unit_test@boost@@@unit_test@boost@@SAAAVresults_collector_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::progress_monitor_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::progress_monitor_t&gt;::instance(void)'::`2'::$S5" (?$S5@?1??instance@?$singleton@Vprogress_monitor_t@unit_test@boost@@@unit_test@boost@@SAAAVprogress_monitor_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::results_collector_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::results_collector_t&gt;::instance(void)'::`2'::$S5" (?$S5@?1??instance@?$singleton@Vresults_collector_t@unit_test@boost@@@unit_test@boost@@SAAAVresults_collector_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::results_collector_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::results_collector_t&gt;::instance(void)'::`2'::$S6" (?$S6@?1??instance@?$singleton@Vresults_collector_t@unit_test@boost@@@unit_test@boost@@SAAAVresults_collector_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::unit_test_log_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::unit_test_log_t&gt;::instance(void)'::`2'::$S7" (?$S7@?1??instance@?$singleton@Vunit_test_log_t@unit_test@boost@@@unit_test@boost@@SAAAVunit_test_log_t@34@XZ@4IA) boost_unit_test_framework-vc71-mt-p-1_40.exp : error LNK2001: unresolved external symbol "unsigned int `public: static class boost::unit_test::unit_test_log_t &amp; __cdecl boost::unit_test::singleton&lt;class boost::unit_test::unit_test_log_t&gt;::instance(void)'::`2'::$S9" (?$S9@?1??instance@?$singleton@Vunit_test_log_t@unit_test@boost@@@unit_test@boost@@SAAAVunit_test_log_t@34@XZ@4IA) </pre><p> Apparently, this is a compiler issue, as the missing symbols are internal variables related to the function-local statics. However, I managed to work it around, please find the patch attached. I didn't test it against more recent MSVC versions, it may happen that the newer compilers require this twist, too. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3435 Trac 1.4.3 Andrey Semashev Fri, 11 Sep 2009 15:46:54 GMT attachment set https://svn.boost.org/trac10/ticket/3435 https://svn.boost.org/trac10/ticket/3435 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">trivial_singleton.hpp.patch</span> </li> </ul> <p> The fix modifies the way singleton instance is acquired </p> Ticket Gennadiy Rozental Sun, 22 Nov 2009 22:41:18 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3435#comment:1 https://svn.boost.org/trac10/ticket/3435#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">worksforme</span> </li> </ul> <p> Works fine for me. </p> <p> How do you build Boost.Test and your test modules? </p> Ticket Andrey Semashev Mon, 23 Nov 2009 05:42:47 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/3435#comment:2 https://svn.boost.org/trac10/ticket/3435#comment:2 <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">worksforme</span> </li> </ul> <p> It doesn't come to the test modules, as Boost.Test doesn't build. The problem is still present in the 1.41 release. </p> <p> Here is my build script, as I run it from Cygwin bash: </p> <pre class="wiki"> if [ ! -f tools/jam/src/bin.ntx86/bjam.exe ] then pushd ./tools/jam/src &gt;/dev/null ./build.bat popd &gt;/dev/null fi export HAVE_ICU=1 export ICU_PATH="$ROOT_DIR/ThirdParty/icu" export ICU_LINK="/LIBPATH:$ROOT_DIR/ThirdParty/icu/win32/lib icuuc.lib icuin.lib icudt.lib" export ZLIB_BINARY=zlib export ZLIB_INCLUDE=$ROOT_DIR/ThirdParty/ZLib/inc export ZLIB_LIBPATH=$ROOT_DIR/ThirdParty/ZLib/lib/win32 tools/jam/src/bin.ntx86/bjam.exe -d+2 -j 2 --stagedir=stage.vc7 toolset=msvc-7.1 stdlib=stlport variant=release link=shared runtime-link=shared threading=multi optimization=speed inlining=full rtti=on exception-handling=on debug-symbols=on "cxxflags=-G7 -arch:SSE2 -Oi -GL" "linkflags=/LTCG /OPT:REF,ICF" --with-test stage </pre><p> I'm using STLPort 5.1.4. The ROOT_DIR variable in the script is D:. I attached the complete build log that shows compiler flags and errors. </p> Ticket Andrey Semashev Mon, 23 Nov 2009 05:43:45 GMT attachment set https://svn.boost.org/trac10/ticket/3435 https://svn.boost.org/trac10/ticket/3435 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">build_log.txt</span> </li> </ul> <p> Complete build for 1.41 </p> Ticket Andrey Semashev Mon, 23 Nov 2009 06:02:46 GMT <link>https://svn.boost.org/trac10/ticket/3435#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3435#comment:3</guid> <description> <p> BTW, without STLPort the problem is still the same. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gennadiy Rozental</dc:creator> <pubDate>Mon, 23 Nov 2009 06:55:57 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3435#comment:4 https://svn.boost.org/trac10/ticket/3435#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> From what I can tell the reason for the linking error is the flag /GL (You really should have found it yourself). Just skip it when you build testing framework. Not sure why you want to build optimized version of UTF in a first place. </p> Ticket