Boost Users :
Subject: Re: [Boost-users] [Regex] Source-only link error in MSVC
Date: 2009-05-19 13:30:53
On Tue, 19 May 2009 03:42:57 -0500 John Maddock
>> error LNK2019: unresolved external symbol
>> AAEAAV12_at_PBD0I@Z) referenced
>> 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
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
Sadly, I never would have figured that out. Thank you very much!
-- 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