Ok, this is making me go nuts. I didn't have this problem before and now it just showed up out of the blue.
I can't seem to be able to compile with Boost libraries against the static multi-threaded runtime libraries (debug or release). Only against the DLL versions, which force my app into a vcredist dependency I don't want.
Boost has been installed from the installer provided by Boostpro. I'm using Boost 1.39.0 and installing for VC 9.0. Only this week I finally decided to upgrade boost. And right into this mess.
Error happens at any level, so for simplicity sake I'm copy-pasting here the code from boost documentation:
Now, this code is inserted into a new empty project. Runtime library is set to Multi-threaded Debug (/MTd). No other changes to default settings except pointing to boost distribution for include headers and library paths.Code:#include <boost/regex.hpp> #include <iostream> #include <string> int main() { std::string line; boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" ); while (std::cin) { std::getline(std::cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) std::cout << matches[2] << std::endl; } }
The debug library for this runtime is libboost_regex-vc90-sgd-1_39.lib. I try to build without adding it and taking advantage of auto-linking, or by adding it. On both cases the linker fails with:
I'm completely stumped. It just refuses to link against the static runtime.1>Linking...
1>teste.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::re_detail::raw_storage::resize(unsigned int)" (?resize@raw_storage@re_detail@boost@@QAEXI@Z) referenced in function "public: void * __thiscall boost::re_detail::raw_storage::extend(unsigned int)" (?extend@raw_storage@re_detail@boost@@QAEPAXI@Z)
1>teste.obj : error LNK2019: unresolved external symbol "public: void * __thiscall boost::re_detail::raw_storage::insert(unsigned int,unsigned int)" (?insert@raw_storage@re_detail@boost@@QAEPAXII@Z) referenced in function "public: struct boost::re_detail::re_syntax_base * __thiscall boost::re_detail::basic_regex_creator<char,struct boost::regex_traits<char,class boost::cpp_regex_traits<char> > >::insert_state(int,enum boost::re_detail::syntax_element_type,unsigned int)" (?insert_state@?$basic_regex_creator@DU?$regex_tra its@DV?$cpp_regex_traits@D@boost@@@boost@@@re_deta il@boost@@QAEPAUre_syntax_base@23@HW4syntax_elemen t_type@23@I@Z)
1>C:\Documents and Settings\Mario Figueiredo\My Documents\Visual Studio 2008\Projects\teste5\Debug\teste5.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Mario Figueiredo\My Documents\Visual Studio 2008\Projects\teste5\teste5\Debug\BuildLog.htm"
1>teste5 - 3 error(s), 0 warning(s)