views:

732

answers:

2

I'm trying to get the Boost library working in my C++ projects in Eclipse. I can successfully build when using header-only libraries in Boost such as the example simple program in the "Getting Started" guide using the lambda header.

I cannot get my project to successfully link to the regex Boost library as shown later in the guide. Under my project properties -> c/c++ build -> settings -> tool settings tab -> libraries, I have added "libboost_regex" to the Libraries box, and "C:\Program Files\boost\boost_1_42_0\bin.v2\libs" to the Library search path box since this is where all the .lib files are. I've even tried adding "libboost_regex-mgw34-mt-d-1_42.lib" to the libraries box instead of "libboost_regex" since that is the exact file name, but this did not work either.

I keep getting an error that says "cannot find -llibboost_regex" when I try to build my project. Any ideas as to how I can fix this?

Edit: on Windows XP, using mingw, and I have tried "boost_regex" as well..

A: 

I believe your lib path is pointing to the wrong place. The libs will be installed to:

boost_install_dir\boost_1_42\lib

I think the default boost_install_dir is "C:\Program Files\Boost" (not sure because I don't use the default install directory).

zdan
I have a "libs" directory, but not "lib" in my boost directory, but this does not actually contain the compiled files which are in the bin.v2\libs directory
MahlerFive
+3  A: 

I just went through the whole process of installing MinGW, compiling boost and installing Eclipse CDT and I'm able to compile simple programs using boost:regex. I'll write down all the steps. I hope that can be of help.

I've installed MinGW and MSYS in their default location.

Here are the step I took to build boost:

  • Download boost-jam-3.1.18-1-ntx86.zip from http://sourceforge.net/projects/boost/files/boost-jam
  • Put bjam.exe somewhere in your PATH
  • Unpack boost in C:\mingw\boost_1_42_0
  • Open an msys terminal window and cd /c/mingw/boost_1_42_0
  • In the boost directory run bjam --build-dir=build toolset=gcc stage

To configure Eclipse:

  • Add CDT to Eclipse 3.5 from the update site
  • Create a new C++ project
  • Under the Project menu select properties
  • Make sure the configuration is Debug [Active]
  • In "C/C++ General" > "Paths and Symbols"

    • Under the Includes tab select the GNU C++ language and add C:\MinGW\boost_1_42_0
    • Under the Library Paths tab add C:\MinGW\boost_1_42_0\stage\lib
  • In "C/C++ Build" > "Settings"

    • Select MinGW C++ Linker > Libraries
    • Click on the add button for Libraries (-l)
    • Type libboost_regex-mgw34-mt-d (without the .lib)

You can then go through the same steps for the Release configuration but use libboost_regex-mgw34-mt instead. Also make sure your source files include <boost/regex.hpp>

Alexandre Jasmin
Thanks a lot! I changed the library paths directory to the stage\lib directory and added the libboost_regex-mgw34-mt-d and it worked!
MahlerFive