[regex] link problem with MSVC

HI,
I had built boost version 1.40 (some time ago) myself with MSVC 2008
Express, a complete build.
I now wanted to use the regex library; I left the default option of
statically linking it in (no #define BOOST_REGEX_DYN_LINK) and also
count on auto-linking (no BOOST_REGEX_NO_LIB).
Using regex_search, I keep getting linker errors:
Error 1 error LNK2019: unresolved external symbol
"__declspec(dllimport) public: void __thiscall
std::_Container_base::_Orphan_all(void)const "
(__imp_?_Orphan_all@_Container_base@std@@QBEXXZ) referenced in function
"public: class std::vector
::operator=(class std::vector
,class std::allocator > > const &)" (??4?$vector@U?$sub_match@PBD@boost@@V?$allocator@U?$sub_match@PBD@boost@@@std@@@std@@QAEAAV01@ABV01@@Z) libboost_regex-vc90-mt-gd-1_40.lib
Error 2 error LNK2019: unresolved external symbol
"__declspec(dllimport) public: __thiscall
std::_Container_base::~_Container_base(void)"
(__imp_??1_Container_base@std@@QAE@XZ) referenced in function "public:
__thiscall std::_Vector_val
::~_Vector_val
,class std::allocator > >(void)" (??1?$_Vector_val@U?$sub_match@PBD@boost@@V?$allocator@U?$sub_match@PBD@boost@@@std@@@std@@QAE@XZ) libboost_regex-vc90-mt-gd-1_40.lib
and some more others. Me doing something wrong or a boost issue ? I tried to disable auto-linking and specifiy the lib (libboost_regex-vc90-mt-gd-1_40.lib for debug build) myself but it does not seem to link it in statically (wants the DLL on startup). many thanks and best, Thomas

I had built boost version 1.40 (some time ago) myself with MSVC 2008 Express, a complete build. I now wanted to use the regex library; I left the default option of statically linking it in (no #define BOOST_REGEX_DYN_LINK) and also count on auto-linking (no BOOST_REGEX_NO_LIB).
Using regex_search, I keep getting linker errors:
<snip> I've never seen those before, the missing symbols are std lib ones not Boost.Regex ones BTW. I would guess there's something unusual about how the library was built or how your app is being built. The quick solution would be to define BOOST_REGEX_NO_LIB and add all the libs/regex/src/*.cpp files directly to your project. Otherwise check that regex really was built with VC9 and not some other compiler by mistake, and check to see what defines and/or "odd" compiler options you may be using in your project. HTH, John.

On 2/21/2011 7:39 PM, John Maddock wrote:
I had built boost version 1.40 (some time ago) myself with MSVC 2008 Express, a complete build. I now wanted to use the regex library; I left the default option of statically linking it in (no #define BOOST_REGEX_DYN_LINK) and also count on auto-linking (no BOOST_REGEX_NO_LIB).
Using regex_search, I keep getting linker errors:
<snip>
I've never seen those before, the missing symbols are std lib ones not Boost.Regex ones BTW. I would guess there's something unusual about how the library was built or how your app is being built. The quick solution would be to define BOOST_REGEX_NO_LIB and add all the libs/regex/src/*.cpp files directly to your project. Otherwise check that regex really was built with VC9 and not some other compiler by mistake, and check to see what defines and/or "odd" compiler options you may be using in your project.
Yes they are std errors but only pop up if I use the regex library (specifically, using regex_search is the offender). To the best of my knowledge I am not using any odd options either for my project or when I had compiled the boost library. The project is a fairly plain-vanilla console application with most options left to the default, only rather unsuspicious include directives and some optimization flags set, but the linker error also comes in debug mode. I am also using the boost threads library and others without any problems. Boost libraries were built with sort of the default bjam toolset=msvc-9.0 --build-type=complete --build-dir=BuildDir stage, so nothing odd there as well. hth, Thomas

I've never seen those before, the missing symbols are std lib ones not Boost.Regex ones BTW. I would guess there's something unusual about how the library was built or how your app is being built. The quick solution would be to define BOOST_REGEX_NO_LIB and add all the libs/regex/src/*.cpp files directly to your project. Otherwise check that regex really was built with VC9 and not some other compiler by mistake, and check to see what defines and/or "odd" compiler options you may be using in your project.
Yes they are std errors but only pop up if I use the regex library (specifically, using regex_search is the offender). To the best of my knowledge I am not using any odd options either for my project or when I had compiled the boost library. The project is a fairly plain-vanilla console application with most options left to the default, only rather unsuspicious include directives and some optimization flags set, but the linker error also comes in debug mode. I am also using the boost threads library and others without any problems.
Boost libraries were built with sort of the default bjam toolset=msvc-9.0 --build-type=complete --build-dir=BuildDir stage, so nothing odd there as well.
Well there's clearly something odd going on because no one else has that issue ;-) Have you tried the usual last ditch resort and rebuilt the libraries? Otherwise just add the source files directly to your project (or create a regex .lib project in your IDE) and build that way. HTH, John.
participants (2)
-
John Maddock
-
Thomas Mang