Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking Boost to my C++ project in Eclipse

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..

like image 257
MahlerFive Avatar asked Mar 25 '10 22:03

MahlerFive


1 Answers

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>

like image 132
Alex Jasmin Avatar answered Nov 03 '22 00:11

Alex Jasmin