[regex] Unresolved external symbols under VC7.1 w/ dynamic linking

Hello, when I define the symbol BOOST_DYN_LINK (in my project settings) I get the following linker errors in MSVC 7.1: FilterDlg.obj : error LNK2001: unresolved external symbol "wchar_t * boost::re_detail::wide_lower_case_map" (?wide_lower_case_map@re_detail@boost@@3PA_WA) FilterDlg.obj : error LNK2001: unresolved external symbol "private: static unsigned short * boost::w32_regex_traits<wchar_t>::wide_unicode_classes" (?wide_unicode_classes@?$w32_regex_traits@_W@boost@@0PAGA) When linking Boost.Regex statically, everything is ok. I am using /Zc:wchar_t ("Treat wchar_t as Built-in type") in my project settings. Any ideas what's going wrong? Regards, Klaus

when I define the symbol BOOST_DYN_LINK (in my project settings) I get the following linker errors in MSVC 7.1:
FilterDlg.obj : error LNK2001: unresolved external symbol "wchar_t * boost::re_detail::wide_lower_case_map" (?wide_lower_case_map@re_detail@boost@@3PA_WA) FilterDlg.obj : error LNK2001: unresolved external symbol "private: static unsigned short * boost::w32_regex_traits<wchar_t>::wide_unicode_classes" (?wide_unicode_classes@?$w32_regex_traits@_W@boost@@0PAGA)
When linking Boost.Regex statically, everything is ok. I am using /Zc:wchar_t ("Treat wchar_t as Built-in type") in my project settings.
Any ideas what's going wrong?
Not really: I've checked and those symbols are exported, and your setup is one we regularly test. Are you able to produce a short test case? Thanks, John.

John Maddock <john <at> johnmaddock.co.uk> writes:
when I define the symbol BOOST_DYN_LINK (in my project settings) I get the following linker errors in MSVC 7.1:
[snip]
When linking Boost.Regex statically, everything is ok. I am using /Zc:wchar_t ("Treat wchar_t as Built-in type") in my project settings.
Any ideas what's going wrong?
Not really: I've checked and those symbols are exported, and your setup is one we regularly test. Are you able to produce a short test case?
Yes. I am not familiar with Boost.Test, so I just wrote a small test program: <code> // Boost includes ------------------------------------------------------------- #define BOOST_DYN_LINK #include <boost/regex.hpp> // Std includes --------------------------------------------------------------- #include <string> int main(int argc, char* argv[]) { boost::basic_regex<wchar_t> expression(L".*"); boost::match_results<std::wstring::const_iterator> result; boost::regex_match( std::wstring(L"Test"), result, expression, boost::match_default | boost::match_not_dot_newline | boost::match_any ); return 0; } </code> My project settings are: - Runtime Lib: Multithreaded-DLL (/MD) - Treat wchar_t as built-in type on (/Zc:wchar_t) - Enable run-time type info on (/GR) MSVC 7.1, Boost Version 1.32.0 I picked only the ones that look relevant to me. If you need more information, please just drop me a note. Anyways, changing the latter two didn't have any effect, and changing the first "is a bad idea".
Thanks,
John.
Thank you. Klaus

#define BOOST_DYN_LINK
OK, that's the problem: BOOST_DYN_LINK is an internal Boost macro that instructs the auto-linking code to link to a dll, but it doesn't tell the code to add __declspec(dllimport) where needed. You should be defining one of: BOOST_ALL_DYN_LINK: make all Boost libs link as dll's. BOOST_REGEX_DYN_LINK: make regex only link as a dll.
My project settings are: - Runtime Lib: Multithreaded-DLL (/MD)
Be careful not to mix /MD with /D_DEBUG, it confuses the auto-link code (not really a Boost issue, it affects any libray that's linked with #pragma comment). HTH, John.

John Maddock <john <at> johnmaddock.co.uk> writes:
#define BOOST_DYN_LINK
OK, that's the problem: BOOST_DYN_LINK is an internal Boost macro [snip] You should be defining one of:
BOOST_ALL_DYN_LINK: make all Boost libs link as dll's. BOOST_REGEX_DYN_LINK: make regex only link as a dll.
D'oh! Thank you.
Be careful not to mix /MD with /D_DEBUG, it confuses the auto-link code (not really a Boost issue, it affects any libray that's linked with #pragma comment).
Yes, I was assuming a release build.
HTH,
It did, thanks.
John.
-- Klaus
participants (2)
-
John Maddock
-
Klaus Nowikow