逐步使用 Boost 和 cygwin
创建一个新项目

最好准确使用本教程中给出的名称。后来问:不行,以后可以更容易找到。
我认为我不需要提及所有T:\
当然必须用您的驱动器替换。
项目名称 :Boost-cyg-Test

现在你的项目应该看起来像

打开 main.cpp
使用以下内容覆盖生成的代码。我们想要做到这一点,首先,一切都可以正常工作。
因此,请不要使用自己的特殊代码。
很难找到故障。然后告诉经过几次询问,得到:
我使用了我自己的代码
#include <iostream>
#include <boost/filesystem.hpp>
using namespace std;
using namespace boost::filesystem;
int main()
{
path p("second.cpp");
if (exists(p)) { std::cout<<p.leaf()<<std::endl; }
}
在本节中,我们假设“boost”已经编译。
转到工具 -> 选项
您的 C++ 代码辅助选项应如下所示。

如果不是这样,我们应该让 Netbeans 为我们创建它。

添加新工具集合

在我们用 OK 完成此对话框后,我们应该找到上面显示的设置。(C++ 代码辅助选项)。
将所有库复制到正确的位置
让我们创建一个新文件夹“boost”。

使用搜索工具,在您编译的 Boost 文件夹中搜索*.a
MyBoost
编译,shared option
因此我们发现:

对于我们的简短应用程序。我们只需要 2 个文件。
libboost_filesystem-gcc45-mt-d-1_53.dll.a
libboost_system-gcc45-mt-d-1_53.dll.a
但是如果我们要复制两个文件,我们可以复制所有文件。
所以标记所有找到.a
的文件并将它们复制到刚刚创建的目录
T:\cygwin\lib\boost
中。
现在我们对我们的.dll
文件做同样的事情。
标记所有.dll
文件并将其复制到您的?:\cygwin\bin
目录中。
如果你只编译过静态库,可以跳过这一点。

现在是时候修改我们的项目设置了。
如您所见,我将源 Boost 文件夹放入 cygwin

和

正如我们上面已经提到的,我们需要两个.a
文件。
使用添加库导航到T:\cygwin\lib\boost
并选择
libboost_filesystem-gcc45-mt-d-1_53.dll.a
libboost_system-gcc45-mt-d-1_53.dll.a
现在您会注意到这个名称已被 netbeans 缩短为:
boost_filesystem-gcc45-mt-d-1_53.dll
boost_system-gcc45-mt-d-1_53.dll

这有点令人困惑。看起来好像a.dll
站在这里。但它确实是一个.a
文件。
在 main.cpp 中设置断点。现在我们开始调试。

我已经用箭头标记了重要的部分,即两个库。
找到所有库,并在 make 完成后停止在断点处。
输出:

为 Cygwin 构建 Boost
对于所有想要使用共享库本身创建提升的人。
下载 boost_1_53_0.zip
在 ?:\cygwin 目录中创建一个文件夹。
boost_1_53_0

将 zip 文件解压缩到该目录中。
它应该看起来像:

打开一个cmd窗口,cd到boost_1_53_0
目录。
为了有一个干净的构建,我们需要一个只有cygwin home
and的 PATH bin
。
在 cmd 类型中。
SET PATH=T:\cygwin;T:\cygwin\bin
并测试路径。
PATH

类型
bootstrap.bat

类型
.\b2 --build-dir=T:\boost-cyg toolset=gcc variant=debug link=shared runtime-link=shared
一段时间后构建完成。
现在您拥有了我们在教程中使用的相同环境。
如果您收到错误:gcc not found
在文件夹中复制(不重命名)?:\cygwin\bin
,例如:(名称可能不同)。
i686-pc-cygwin-gcc-4.5.3.exe
去gcc.exe
和
i686-pc-cygwin-g++-4.exe
去g++.exe
希望它可以帮助你。