issue building boost::regex on win32

I have tried to install the boost libraries as per http://wagjo.com/index.php?id=27

When i try to declare a regex type i run into linker issues.

eg
boost::regex re("abcde");

gives the linker error
  [Linker error] undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'

it has no issue with
boost::regex re();
though

any pointers please.

Also I am developing using dev-cpp on windows.

LVL 3
swervesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
Have you linked you project against the boost regex library? Under Visual Studio this isn't necessary because it uses automatic dynamic linking but with devcpp you'll need to ensure you manially link to the boost regex library.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
evilrixSenior Software Engineer (Avast)Commented:
>>it has no issue with
>> boost::regex re();

Assuming you've not linked to the regex librayr it's probably because the default constructor doesn't call any functions that have linkage.
0
evilrixSenior Software Engineer (Avast)Commented:
Oh, and you can download pre-built versions of Boost for Windows here:http://www.boostpro.com/download
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

jkrCommented:
Stupid question - does

boost::regex re(L"abcde");

work? If so, you might be compiling as UNICODE, so the ANSI string literal in the constructor might cause the error.
0
swervesAuthor Commented:
I "think" i am linking correctly:

the compile log shows

===============================================
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing  make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe main.o  -o "assp_log_parser.exe" -L"C:/Dev-Cpp/lib" -L"C:/Boost/boost_1_39_0/lib"  

main.o(.text$_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)]+0x22):main.cpp: undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
collect2: ld returned 1 exit status

make.exe: *** [assp_log_parser.exe] Error 1

Execution terminated
=========================================

which i think means i am linking using the directory "C:/Boost/boost_1_39_0/lib".  I was thinking maybe i dont have everything in that directory that should be.
there are 4 files with regex in their name such as libboost_regex-vc90-mt-gd-1_39.lib

which actually looking at it is slightly concerning, are these libraries for the visual c++ compiler and not the dev-cpp one?
 
0
swervesAuthor Commented:
jkr,

i tried the unicode test but that doesnt seem to be it.
It doesnt compile this time, saying "no matching function.." so i think that means that's not it.
0
evilrixSenior Software Engineer (Avast)Commented:
>> Stupid question - does
>> boost::regex re(L"abcde");
>> work?

char should work, wregex would work with wchar_t...
   explicit basic_regex(const  charT* p, flag_type f = regex_constants::normal);

http://www.boost.org/doc/libs/1_39_0/libs/regex/doc/html/boost_regex/ref/basic_regex.html

Your linker command only contains the path to the regex libraries, but you still need to provide the library itself using the -l flag

Try this...

g++.exe main.o  -o "assp_log_parser.exe" -L"C:/Dev-Cpp/lib" -L"C:/Boost/boost_1_39_0/lib"  -l <library-name>

Where library-name is the name of the library you want to link against.

Also, I'm not sure you can link against the vc90 versions of this libraries, since they are designed for and have linkage specific for Microsoft compilers. You might need to link against the gcc or g++ libraries (since devcpp using Mingw and that is more or less gcc/g++ for Windows. You'll have to play with this a little though, I've never triesd to do this with devcpp.
0
Infinity08Commented:
>> Also, I'm not sure you can link against the vc90 versions of this libraries, since they are designed for and have linkage specific for Microsoft compilers. You might need to link against the gcc or g++ libraries (since devcpp using Mingw and that is more or less gcc/g++ for Windows. You'll have to play with this a little though, I've never triesd to do this with devcpp.

Here's a boost DevPak (used for installing it in Dev-C++), which contains most static libraries (with multi-threading support enabled) for the latest version of boost :

        http://devpaks.org/details.php?devpak=253
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.