Opened 13 years ago
Closed 13 years ago
#3435 closed Bugs (wontfix)
Linking failure with MSVC 7.1
Reported by: | Andrey Semashev | Owned by: | Gennadiy Rozental |
---|---|---|---|
Milestone: | Boost 1.41.0 | Component: | test |
Version: | Boost 1.40.0 | Severity: | Problem |
Keywords: | msvc | Cc: |
Description
While trying to build Boost.Test 1.40 into a shared library with MSVC 7.1 I encountered the following linking errors:
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 & __cdecl boost::unit_test::singleton<class boost::unit_test::results_collector_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::unit_test_monitor_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::results_collector_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::unit_test_log_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::unit_test_log_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::results_collector_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::unit_test_log_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::results_collector_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::progress_monitor_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::results_collector_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::results_collector_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::unit_test_log_t>::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 & __cdecl boost::unit_test::singleton<class boost::unit_test::unit_test_log_t>::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)
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.
Attachments (2)
Change History (6)
by , 13 years ago
Attachment: | trivial_singleton.hpp.patch added |
---|
comment:1 by , 13 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Works fine for me.
How do you build Boost.Test and your test modules?
comment:2 by , 13 years ago
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
It doesn't come to the test modules, as Boost.Test doesn't build. The problem is still present in the 1.41 release.
Here is my build script, as I run it from Cygwin bash:
if [ ! -f tools/jam/src/bin.ntx86/bjam.exe ] then pushd ./tools/jam/src >/dev/null ./build.bat popd >/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
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.
comment:4 by , 13 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
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.
The fix modifies the way singleton instance is acquired