how to get regex to link in windows?
Another frustrating day trying to compile some code...
I'm trying use the regex library. My application is
compiled using Multi-threaded Debug DLL (/MDd). I
specified the following library
libboost_regex-vc71-mt.lib and all I get are link
errors.
My application is a console app so I defined
BOOST_REGEX_NO_W32
I've tried setting BOOST_REGEX_DYN_LINK and
BOOST_REGEX_NO_LIB but that doesn't cut it.
The funny thing is that Im also using the filesystem
library, and I link with the same type of library
libboost_filesystem-vc71-mt.lib and I don't get any
problems with the compiler.
I'd appreciate if someone can point out what I'm doing
wrong.
Thanks,
Alexis
Try #1: Defining
BOOST_REGEX_DYN_LINK
BOOST_REGEX_NO_LIB
BOOST_LIB_DIAGNOSTIC
BOOST_REGEX_NO_W32
Specifying as the link libraries
libboost_filesystem-vc71-mt.lib
libboost_regex-vc71-mt.lib
Linking to lib file:
libboost_filesystem-vc71-mt-gd-1_32.lib
Linking to lib file: boost_regex-vc71-mt-gd-1_32.lib
Linking...
test_csfwrapper.obj : error LNK2019: unresolved
external symbol "__declspec(dllimport) void * __cdecl
boost::re_detail::get_mem_block(void)"
(__imp_?get_mem_block@re_detail@boost@@YAPAXXZ)
referenced in function "public: __thiscall
boost::re_detail::save_state_init::save_state_init(struct
boost::re_detail::saved_state * *,struct
boost::re_detail::saved_state * *)"
(??0save_state_init@re_detail@boost@@QAE@PAPAUsaved_state@12@0@Z)
test_csfwrapper.obj : error LNK2019: unresolved
external symbol "__declspec(dllimport) void __cdecl
boost::re_detail::put_mem_block(void *)"
(__imp_?put_mem_block@re_detail@boost@@YAXPAX@Z)
referenced in function "public: __thiscall
boost::re_detail::save_state_init::~save_state_init(void)"
(??1save_state_init@re_detail@boost@@QAE@XZ)
Try #2: Defining
BOOST_LIB_DIAGNOSTIC
BOOST_REGEX_NO_W32
Linking to lib file:
libboost_filesystem-vc71-mt-gd-1_32.lib
Linking to lib file:
libboost_regex-vc71-mt-gd-1_32.lib
Linking...
libboost_regex-vc71-mt-gd-1_32.lib(regex.obj) : error
LNK2005: "public: virtual __thiscall
boost::bad_pattern::~bad_pattern(void)"
(??1bad_pattern@boost@@UAE@XZ) already defined in
libboost_regex-vc71-mt.lib(regex.obj)
libboost_regex-vc71-mt-gd-1_32.lib(regex.obj) : error
LNK2005: "public: virtual __thiscall
boost::bad_expression::~bad_expression(void)"
(??1bad_expression@boost@@UAE@XZ) already defined in
libboost_regex-vc71-mt.lib(regex.obj)
libboost_regex-vc71-mt-gd-1_32.lib(regex.obj) : error
LNK2005: "public: __thiscall
boost::regbase::regbase(void)"
(??0regbase@boost@@QAE@XZ) already defined in
libboost_regex-vc71-mt.lib(regex.obj)
libboost_regex-vc71-mt-gd-1_32.lib(regex.obj) : error
LNK2005: "public: __thiscall
boost::regbase::regbase(class boost::regbase const &)"
(??0regbase@boost@@QAE@ABV01@@Z) already defined in
libboost_regex-vc71-mt.lib(regex.obj)
libboost_regex-vc71-mt-gd-1_32.lib(c_regex_traits.obj)
: error LNK2005: "protected: static char *
boost::re_detail::c_traits_base::regex_message_catalogue"
(?regex_message_catalogue@c_traits_base@re_detail@boost@@1PADA)
already defined in
libboost_regex-vc71-mt.lib(c_regex_traits.obj)
libboost_regex-vc71-mt-gd-1_32.lib(c_regex_traits.obj)
: error LNK2005: "class std::basic_string
Another frustrating day trying to compile some code...
I'm trying use the regex library. My application is compiled using Multi-threaded Debug DLL (/MDd). I specified the following library libboost_regex-vc71-mt.lib and all I get are link errors.
libboost_regex-vc71-mt.lib is compiled for the release runtime (/MD), so I'm not surprised you got errors. Why not just place the libraries in your compilers search path, and let auto-linking take care of selecting the right one?
My application is a console app so I defined BOOST_REGEX_NO_W32
If you do that, then you also have to compile the library with BOOST_REGEX_NO_W32 defined (put it in boost/regex/user.hpp), however, you can use the default compiled version perfectly well in a console app, so this shouldn't be necessary, unless you really want to avoid linking to user32.lib. John.
participants (2)
-
Alexis H. Rivera-Rios
-
John Maddock