在Eclipse中链接Boost到我的c++项目

时间:2022-09-09 08:49:54

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.

我正在尝试让Boost库在Eclipse中的c++项目中工作。我可以在Boost中使用header-only库时成功构建,例如使用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.

我无法让我的项目成功链接到regex Boost库,如后面的指南所示。在我的项目属性—> c/c+ build ->设置—>工具设置选项卡—>库中,我在库框中添加了“libboost_regex”和“c:\程序文件增强\boost_1_42_0\bin”。v2\libs“到库搜索路径框,因为这是所有.lib文件所在的地方。我甚至尝试过添加“libboost_regex-mgw34-mt-d-1_42”。“lib”到libraries框而不是“libboost_regex”,因为这是确切的文件名,但这也不起作用。

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?

当我尝试构建我的项目时,我总是会得到一个“找不到-llibboost_regex”的错误。有什么办法可以解决这个问题吗?

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

编辑:在Windows XP上,使用mingw,我也试过boost_regex。

3 个解决方案

#1


19  

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.

我刚刚完成了安装MinGW、编译boost和安装Eclipse CDT的整个过程,并且能够使用boost:regex编译简单的程序。我把所有的步骤都写下来。我希望这能有所帮助。

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

我在它们的默认位置安装了MinGW和MSYS。

Here are the step I took to build boost:

以下是我建立boost的步骤:

  • Download boost-jam-3.1.18-1-ntx86.zip from http://sourceforge.net/projects/boost/files/boost-jam
  • 下载boost-jam-3.1.18-1-ntx86。zip从http://sourceforge.net/projects/boost/files/boost-jam
  • Put bjam.exe somewhere in your PATH
  • 把bjam。在你的路上
  • Unpack boost in C:\mingw\boost_1_42_0
  • 解压缩在C:\ mingw \ boost_1_42_0
  • Open an msys terminal window and cd /c/mingw/boost_1_42_0
  • 打开msys终端窗口和cd /c/mingw/boost_1_42_0
  • In the boost directory run bjam --build-dir=build toolset=gcc stage
  • 在boost目录中运行bjam—build-dir=build toolset=gcc stage

To configure Eclipse:

配置Eclipse:

  • Add CDT to Eclipse 3.5 from the update site
  • 从更新站点添加CDT到Eclipse 3.5。
  • Create a new C++ project
  • 创建一个新的c++项目
  • Under the Project menu select properties
  • 在项目菜单下选择属性
  • Make sure the configuration is Debug [Active]
  • 确保配置是Debug [Active]
  • In "C/C++ General" > "Paths and Symbols"

    在“C/C++ General”>“路径和符号”中

    • Under the Includes tab select the GNU C++ language and add C:\MinGW\boost_1_42_0
    • 在include选项卡下选择GNU c++语言并添加C:\MinGW\boost_1_42_0
    • Under the Library Paths tab add C:\MinGW\boost_1_42_0\stage\lib
    • 在库路径选项卡下添加C:\MinGW\boost_1_42_0\stage\lib
  • In "C/C++ Build" > "Settings"

    在“C/ c++构建”>“设置”中

    • Select MinGW C++ Linker > Libraries
    • 选择MinGW c++ Linker >库
    • Click on the add button for Libraries (-l)
    • 单击库的add按钮(-l)
    • Type libboost_regex-mgw34-mt-d (without the .lib)
    • 输入libboost_regex-mgw34-mt-d(没有.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>

然后,您可以使用libboost_regex-mgw34-mt来完成发布配置的相同步骤。还要确保源文件包括

#2


7  

To link to boost library in eclipse you need to set both the eclipse's project library path(the one with the -L) and the name of the library(the one with the -l).

要链接到eclipse中的boost库,需要同时设置eclipse的项目库路径(带有-L的路径)和库的名称(带有-L的路径)。

The prefix 'lib' and the extension of the library's name must be removed:- eg: libboost_regex.a should be specified as boost_regex.

必须删除前缀“lib”和库名的扩展名:-例如:libboost_regex。应该指定为boost_regex。

#3


0  

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

我相信你的*之路指向错误的地方。安装libs的目的是:

boost_install_dir\boost_1_42\lib

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

我认为默认的boost_install_dir是“C:\程序文件\Boost”(不确定,因为我不使用默认的安装目录)。

#1


19  

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.

我刚刚完成了安装MinGW、编译boost和安装Eclipse CDT的整个过程,并且能够使用boost:regex编译简单的程序。我把所有的步骤都写下来。我希望这能有所帮助。

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

我在它们的默认位置安装了MinGW和MSYS。

Here are the step I took to build boost:

以下是我建立boost的步骤:

  • Download boost-jam-3.1.18-1-ntx86.zip from http://sourceforge.net/projects/boost/files/boost-jam
  • 下载boost-jam-3.1.18-1-ntx86。zip从http://sourceforge.net/projects/boost/files/boost-jam
  • Put bjam.exe somewhere in your PATH
  • 把bjam。在你的路上
  • Unpack boost in C:\mingw\boost_1_42_0
  • 解压缩在C:\ mingw \ boost_1_42_0
  • Open an msys terminal window and cd /c/mingw/boost_1_42_0
  • 打开msys终端窗口和cd /c/mingw/boost_1_42_0
  • In the boost directory run bjam --build-dir=build toolset=gcc stage
  • 在boost目录中运行bjam—build-dir=build toolset=gcc stage

To configure Eclipse:

配置Eclipse:

  • Add CDT to Eclipse 3.5 from the update site
  • 从更新站点添加CDT到Eclipse 3.5。
  • Create a new C++ project
  • 创建一个新的c++项目
  • Under the Project menu select properties
  • 在项目菜单下选择属性
  • Make sure the configuration is Debug [Active]
  • 确保配置是Debug [Active]
  • In "C/C++ General" > "Paths and Symbols"

    在“C/C++ General”>“路径和符号”中

    • Under the Includes tab select the GNU C++ language and add C:\MinGW\boost_1_42_0
    • 在include选项卡下选择GNU c++语言并添加C:\MinGW\boost_1_42_0
    • Under the Library Paths tab add C:\MinGW\boost_1_42_0\stage\lib
    • 在库路径选项卡下添加C:\MinGW\boost_1_42_0\stage\lib
  • In "C/C++ Build" > "Settings"

    在“C/ c++构建”>“设置”中

    • Select MinGW C++ Linker > Libraries
    • 选择MinGW c++ Linker >库
    • Click on the add button for Libraries (-l)
    • 单击库的add按钮(-l)
    • Type libboost_regex-mgw34-mt-d (without the .lib)
    • 输入libboost_regex-mgw34-mt-d(没有.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>

然后,您可以使用libboost_regex-mgw34-mt来完成发布配置的相同步骤。还要确保源文件包括

#2


7  

To link to boost library in eclipse you need to set both the eclipse's project library path(the one with the -L) and the name of the library(the one with the -l).

要链接到eclipse中的boost库,需要同时设置eclipse的项目库路径(带有-L的路径)和库的名称(带有-L的路径)。

The prefix 'lib' and the extension of the library's name must be removed:- eg: libboost_regex.a should be specified as boost_regex.

必须删除前缀“lib”和库名的扩展名:-例如:libboost_regex。应该指定为boost_regex。

#3


0  

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

我相信你的*之路指向错误的地方。安装libs的目的是:

boost_install_dir\boost_1_42\lib

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

我认为默认的boost_install_dir是“C:\程序文件\Boost”(不确定,因为我不使用默认的安装目录)。