Boost logo

Boost Users :

Subject: Re: [Boost-users] [Regex] Source-only link error in MSVC
From: dtexg_at_[hidden]
Date: 2009-05-19 13:30:53


On Tue, 19 May 2009 03:42:57 -0500 John Maddock
<john_at_[hidden]> wrote:
>> [...]
>> error LNK2019: unresolved external symbol
>> [...]
>> (?do_assign@?$basic_regex_at_DU?$regex_traits_at_DV?$
>> w32_regex_traits_at_D@boost@@@boost@@@boost@@
>> AAEAAV12_at_PBD0I@Z) referenced
>> [...]
>> (?assign@?$basic_regex_at_DU?$regex_traits_at_DV?$
>> w32_regex_traits_at_D@boost@@@boost@@@boost@@
>> QAEAAV12_at_PBD0I@Z)
>> [...]
>> I wrote the following code:
>>
>> #define BOOST_REGEX_SOURCE
>> #include <boost/regex.hpp>
>>
>> int main()
>> {
>> boost::regex r("a");
>> return 0;
>> }
>>
>> Everything compiles, but linking fails with the above error.
>> [...]
>>
>> In a post from 2006, John wrote, "if you are doing something,
>> umm, strange, and you can't track down the cause of the error,
>> you can always just add the regex source directly to your
>> application," but I've not seen this successfully demonstrated
>> in Visual C++. I'm just looking for an absolutely parsimonious
>> way to add Boost Regex to a VC++ project.
>
>Well, you need to do what I said, not what you did ;-)
>
>Take all the .cpp files in libs/regex/src and add them to your
>console project's source, build and voila, it should all work.
>
>BTW use BOOST_REGEX_NO_LIB not BOOST_REGEX_SOURCE in your source
>files, as the latter is for private regex use only and most
>certainly does not do what you think it does.
>
>In point of fact I do this all the time, so it definitely does
>work.
>
>HTH, John.

My embarrassment is outstripped only by my gratitude. That did
help completely, so I just want to confirm it for indexing and
posterity: I changed the #define BOOST_REGEX_SOURCE to
BOOST_REGEX_NO_LIB (or BOOST_ALL_NO_LIB) instead, then right-
clicked on Source Files, chose Add -> Existing Item, and added all
the .cpp files in libs/regex/source. When I built, it compiled all
those .cpp files (where obviously it wasn't before), then linked
successfully and everything just worked and everyone lived happily
ever after.

Sadly, I never would have figured that out. Thank you very much!

/Eric

--
Wanna lose weight?  Weight Loss Programs that work. Click here.
 http://tagline.hushmail.com/fc/BLSrjkqbR3flkqN6HzqHIZfbT5vIrA1g60gAsnOhshGiYDtV96xrgyLp1So/

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net