如何在 Eclipse 中使用 Boost?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39320809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can one use Boost with Eclipse?
提问by Evan Weissburg
I'm having a lot of trouble installing Boost for use with Eclipse C++ (compiler MinGW).
我在安装 Boost 以与 Eclipse C++(编译器 MinGW)一起使用时遇到了很多麻烦。
I first tried downloading the zip at https://sourceforge.net/projects/boost/files/boost/1.61.0/
. After it downloaded, I brought it to my second drive, extracted the files there, cd there, and then ran ./bootstrap.bat gcc
, which appeared to run successfully.
我首先尝试下载 zip 文件https://sourceforge.net/projects/boost/files/boost/1.61.0/
。下载后,我把它带到我的第二个驱动器,在那里解压缩文件,在那里 cd,然后运行./bootstrap.bat gcc
,它似乎运行成功。
Then, I ran b2 install --prefix="D:\boostfiles" toolset=gcc
and it took about 30 minutes to create a lot of files starting with bin.v2
and ending with rst
.
然后,我跑b2 install --prefix="D:\boostfiles" toolset=gcc
了大约 30 分钟,创建了很多bin.v2
以rst
.
However, #include <boost/asio.hpp>
still gives an error. Is there somewhere the files are supposed to be?
但是,#include <boost/asio.hpp>
还是报错。文件应该在某个地方吗?
For reference, my file structure includes the original boost_1_61_0
extracted folder, a folder that boost was installed to called boostfiles
, and a folder called PFiles
that includes both eclipse
and MinGW
.
作为参考,我的文件结构包括原始boost_1_61_0
提取的文件夹、安装了 boostboostfiles
的文件夹,以及一个文件夹PFiles
,其中包含eclipse
和MinGW
.
Please keep it simple, I'm pretty new. Thanks!
请保持简单,我很新。谢谢!
回答by Evan Weissburg
After doing what I originally posted to install and configure Boost, follow these simple steps:
完成我最初发布的安装和配置 Boost 的操作后,请按照以下简单步骤操作:
Go to Project Settings -> C/C++ Build -> Settings:
转到项目设置 -> C/C++ 构建 -> 设置:
C++ Compiler -> Includes -> Include paths -> Add...
C++ 编译器 -> 包含 -> 包含路径 -> 添加...
Add "(directory)\include\boost_x_xx"
添加“(目录)\include\boost_x_xx”
C++ Linker -> Libraries -> Library search path -> Add...
C++ 链接器 -> 库 -> 库搜索路径 -> 添加...
Add "(target_directory)\lib"
添加 "(target_directory)\lib"
C++ Linker -> Libraries -> Libraries -> Add...
C++ 链接器 -> 库 -> 库 -> 添加...
Add (name of library without beginning "lib" or ending ".a")
添加(库名称不以“lib”开头或以“.a”结尾)
For example: libboost_system-mgw49-mt-1_61.a
becomes boost_system-mgw49-mt-1_61
.
例如:libboost_system-mgw49-mt-1_61.a
变成boost_system-mgw49-mt-1_61
.
回答by rustyx
Try adding Boost to the Include and Library search paths.
尝试将 Boost 添加到 Include 和 Library 搜索路径。
Go to Project Settings-> C/C++ Build-> Settings:
转到项目设置-> C/C++ 构建->设置:
C++ Compiler-> Includes -> Include paths -> Add...
- Add "<target_dir>\include\boost_x_xx"
C++ Linker-> Libraries -> Library search path -> Add...
- Add "<target_dir>\lib"
C++ 编译器-> 包含 -> 包含路径 -> 添加...
- 添加“<target_dir>\include\boost_x_xx”
C++ 链接器-> 库 -> 库搜索路径 -> 添加...
- 添加“<target_dir>\lib”