
I wrote the following code:
#define BOOST_REGEX_SOURCE #include
int main() { boost::regex r("a"); return 0; }
Everything compiles, but linking fails with the above error. The same error results if I try this:
boost::regex * p = new boost::regex("a");
Or if I use boost::wregex, or boost::basic_regex
>, etc. Also, the outcome is the same whether I #define BOOST_REGEX_SOURCE, BOOST_REGEX_NO_LIB, or BOOST_ALL_NO_LIB, and whether I define them in the .cpp or in Project -> Properties, Configuration Properties -> C/C++ -> Preprocessor: Preprocessor Definitions, and whether I #include or , and whether I use Debug or Release configuration. If I put a #error by the do_assign implementation in boost/regex/v4/basic_regex.hpp, it gets hit, so the implementation isn't being #if'ed away somehow.
It will build successfully if, in the .cpp file in which main() resides, I write an implementation and replace all the template arguments, but besides being vulgar, this kludge also fails (with compiler errors) if I try to copy-and-paste the full implementation from basic_regex.hpp, so it's untenable as a workaround.
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.