|
Boost Users : |
Subject: [Boost-users] [Regex] Source-only link error in MSVC
From: dtexg_at_[hidden]
Date: 2009-05-18 21:33:38
Hi,
I'm trying to include the Boost Regex source in a Visual C++
project, but I get the following linker error: (indented for
legibility)
error LNK2019: unresolved external symbol
"private: class boost::basic_regex<
char,
struct boost::regex_traits<
char,
class boost::w32_regex_traits<char> > > &
__thiscall boost::basic_regex<
char,
struct boost::regex_traits<
char,
class boost::w32_regex_traits<char> > >::
do_assign(
char const *,
char const *,
unsigned int)"
(?do_assign@?$basic_regex_at_DU?$regex_traits_at_DV?$w32_regex_traits_at_D@bo
ost@@@boost@@@boost@@AAEAAV12_at_PBD0I@Z)
referenced in function "public: class boost::basic_regex<
char,
struct boost::regex_traits<
char,
class boost::w32_regex_traits<char> > > &
__thiscall boost::basic_regex<
char,
struct boost::regex_traits<
char,
class boost::w32_regex_traits<char> > >::
assign(
char const *,
char const *,
unsigned int)"
(?assign@?$basic_regex_at_DU?$regex_traits_at_DV?$w32_regex_traits_at_D@boost
@@@boost@@@boost@@QAEAAV12_at_PBD0I@Z)
Here are the steps I'm taking:
I downloaded the latest Boost (boost_1_39_0.zip), and extracted it
all into its own directory; I've tried extracting with both the
built-in Windows Zip Folder support and the latest WinRAR.
I did not do any making (nmake) or building on the Boost source --
after extracting, I don't touch this directory directly at all.
In both Visual Studio 2005 and Visual C++ 2008 Express Edition
(http://www.microsoft.com/express/vc/), I created a new empty
console project, and I added a new .cpp file to the project.
I went to Project -> Properties, Configuration Properties -> C/C++ -
> General: Additional Include Directories, and (for the
"Active(Debug)" configuration) added the full path of the directory
containing the source, so that "boost" is a subdirectory in the
selected directory.
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. 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<char,boost::regex_traits<char,boost::w32_regex_tr
aits<char>>>, 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 <boost/regex.hpp> or
<boost/regex/v4/regex.hpp>, 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.
/Eric
-- Free information on Digital Photography. Click Now! http://tagline.hushmail.com/fc/BLSrjkqZZHWE3MuglDmDyK5F8gPPnxz3V9yL7kN5dsQjQesHFuiJ5XUKra4/
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