OSX中的Netbeans和Boost库

时间:2014-11-07 08:21:06

标签: c++ regex macos boost netbeans

到目前为止,我已经使用brew下载了boost库并找到了它们的位置并将它们复制到我的主文件夹中。

我试图密切关注如何从Windows教程添加这些库,但我似乎错过了一些东西。编译后......

#include <iostream>
#include <string>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main() {
    string s = "This is my simple sample text, really.";
    regex re(",|:|-|\s+");
    sregex_token_iterator my_iter(s.begin( ), s.end( ), re, -1);
    sregex_token_iterator my_end;
    while (my_iter != my_end)
        cout << *my_iter++ << 'n';
    return (EXIT_SUCCESS);
}

我只是收到一条错误,指出#include <boost/regex.hpp> file not found

使用

  • Netbeans 8.0.1
  • Mac OS 10.9.5

大多数教程都展示了如何使用cygwin设置,因为我在Windows上并不适用于我,并且没有有用或易于学习的Mac OS教程。

请感谢您对此事的任何帮助。

1 个答案:

答案 0 :(得分:0)

经过反复试验,我已经弄明白了!

因此,在Netbeans 8.0.1中,您要为正则表达式设置的目的是:

Netbeans>Preferences select the C/C++ tab下,然后在此窗口中点按"Code Assistance",然后点按"C++ Compiler"

"Include Directories"中,您要添加保存boost库和头文件的位置,在我的机器上安装到     /usr/local/Cellar/boost/1.56.0 你的可能会有所不同。

完成后,点击"Apply"即可关闭此窗口。

然后我使用原始帖子中的代码创建了一个新的c ++项目。

一旦你可以编译一个“Hello World”,就可以用我原来的帖子替换你的代码。

在项目文件夹所在的左侧(默认),右键单击该文件夹并选择"Properties"。然后你应该得到这个窗口。导航到"C++ Compiler"选项下的"Build"

还记得我们如何找到包含文件和库文件的文件夹?在"Include Directories"部分执行相同操作,但这次您将选择包含.hpp文件的文件夹。就我而言,它是"/usr/local/Cellar/boost/1.56.0/include" 点击"Apply"

这样可以处理头文件。现在让我们来做库文件!

完成后,导航到同一选项窗口中的"Linker"选项。我们现在在。

"Addition Library Directories"下找到包含动态和静态库的文件夹。这些文件类型应以.a or .dylib.结尾 我的位于"/usr/local/Cellar/boost/1.56.0/lib"

现在你要做的就是选择右边的"Libraries" and the "...",这会给你一个新窗口。

在这里,您将选择"Add Library File"并添加以下内容......

他们应该贴上标签:

"libboost_program_options-mt.dylib"
"libboost_regex-mt.dylib"

完成此操作后,使用上面的代码构建并运行您的结果应该是: "Thin in my nimple nample textn really.n"

希望这能有所帮助!

相关问题