添加Boost库为C ++在OS X上的Eclipse项目 [英] Adding Boost Library to a C++ project in OS X Eclipse

查看:266
本文介绍了添加Boost库为C ++在OS X上的Eclipse项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用使用eclipse升压文件系统库得到一个C ++项目设置。我跟着安装提振这些方向在我的系统。方向在哪里pretty多少

I am have been attempting to get a C++ project setup using boost file system library using eclipse. I followed these directions to install boost on my system. The directions where pretty much


  1. 下载

  2. 提取

  3. 运行bootstrap.sh

  4. 运行./bjam架构=结合

这似乎去罚款,没有错误。然后我启动了Eclipse和创建一个名为测试一个名为TEST.CPP一个文件一个新的测试项目。在它的code是:

That seemed to go fine, no errors. I then fired up eclipse and created a new test project called test with a single file called test.cpp. The code in it is:

#include <stdio.h>
#include <boost/filesystem.hpp>

int main() {
    boost::filesystem::path path("/Users/schoen"); // random pathname
    bool result = boost::filesystem::is_directory(path);
    printf("Path is a directory : %d\n", result);
    return 0;
}

这仅仅是一些简单的,以确保它是所有正确设置。当然,我想在这一点上编译和失败。做了一些谷歌上搜索,发现网站。它说,通过转到项目属性,并加入boost_filesystem升压库添加到链接器。我想这一点,并且也没有工作。

This is just something simple to make sure it is all set up correctly. Of course I tried to compile at this point and it failed. Did some googling and found this site. It said to add the boost library to the linker by going to project properties and adding "boost_filesystem". I tried this, and well it didn't work.

有人能指出我在正确的方向或者给我一个提示,如何建立加速在Eclipse项目?

我是新的C ++和Eclipse,大多数我的经验是在Java中使用Netbeans。所以我pretty丧失的时刻。

I am new to C++ and Eclipse, and most my experience is in Java with Netbeans. So I am pretty lost at the moment.

更新

我只是想基于给出的答案是我曾尝试更新。

I just wanted to update on what I have tried based on the answers given.

根据Alex的建议,我加boost_system和boost_filesystem的链接列表。我仍然得到同样的编译器错误。

Based on Alex's suggestion I added boost_system and boost_filesystem to the linker list. I was still getting the same compiler errors.

继RVE我加入了路径Boost库到库搜索路径的建议。当这个没有工作。我清理了链接列表,并与刚刚库搜索路径尝试过。这也没有工作。

Following the suggestion from rve I added the path to the boost libraries to the Library search path. When this did not work. I cleared out the linker list and tried it with just the library search path. This also did not work.

然后我清除了库搜索路径。然后我手动编辑链接器窗口中的命令是G ++ -L /用户/ jacobschoen /库/ boost_1_45_0 /台/ lib目录-lboost -lboost_filesystem。这也没有工作。

I then cleared the Library search path. I then manually edited the command on the linker window to be 'g++ -L/Users/jacobschoen/Library/boost_1_45_0/stage/lib -lboost -lboost_filesystem'. This also did not work.

在所有这些我试着设置路径,以提高被'/用户/ jacobschoen /库/ boost_1_45_0和/用户/ jacobschoen /库/ boost_1_45_0 /台/ lib目录。但是都没有成功。

In all of these I tried setting the path to boost to be '/Users/jacobschoen/Library/boost_1_45_0' and '/Users/jacobschoen/Library/boost_1_45_0/stage/lib'. Neither worked.

由于要求comiler错误上述code是:

As requested the comiler error for the above code is:

**** Build of configuration Debug for project test ****

make all 
Building file: ../src/test.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test.d" -MT"src/test.d" -o"src/test.o" "../src/test.cpp"
../src/test.cpp:10:32: warning: boost/filesystem.hpp: No such file or directory
../src/test.cpp: In function 'int main()':
../src/test.cpp:13: error: 'boost' has not been declared
../src/test.cpp:13: error: expected `;' before 'path'
../src/test.cpp:14: error: 'boost' has not been declared
../src/test.cpp:14: error: 'path' was not declared in this scope
make: *** [src/test.o] Error 1

如果任何人有任何进一步的建议,我仍然在努力。

If any one has any further suggestions I am still trying.

第二次修订
在由rholmes建议我增加了一个包括库与链接列表和库搜索路径一起。所以,现在的编译错误是:

Second Update On a suggestion by rholmes I added an include library along with the linker list and library search path. So now the compile error is:

**** Build of configuration Debug for project test ****

make all 
Building target: test
Invoking: MacOS X C++ Linker
g++ -L/Users/jacobschoen/Library/boost_1_45_0 -o "test"  ./src/test.o   -lboost_system -lboost_filesystem
ld: library not found for -lboost_system
collect2: ld returned 1 exit status
make: *** [test] Error 1

任何想法?

推荐答案

不知道,你这样做是Eclipse的这些天,但在Eclipse的include路径应该是路径到主升压目录(/用户/ jacobschoen /图书馆/ boost_1_45_0?)。编译器行应该有一些像在它下面,我会想:

Not sure where you do this in Eclipse these days, but under the include paths for Eclipse should be the path to the main boost directory (/Users/jacobschoen/Library/boost_1_45_0?). The compiler line should have something like the following in it, I would think:

中调用:GCC C ++编译器

Invoking: GCC C++ Compiler

G ++ -I /用户/ jacobschoen /库/ boost_1_45_0 -O0 -g3 -Wall -c -fmessage长度= 0 -MMD(等)

g++ -I/Users/jacobschoen/Library/boost_1_45_0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD (etc..)

更新:看看我的系统上你的链接路径可能是更恰当:

Update: Looking at my system, the linker path on yours might be more appropriately:

-I /用户/ jacobschoen /库/ boost_1_45_0 /台/ lib目录

-I/Users/jacobschoen/Library/boost_1_45_0/stage/lib

根据,当然,在您在安装和内置升压 - 这是我最近的一个完整的源代码编译的尝试。取决于如何获得升压,这可能会或可能不会是不同的。最近,我重做我的Mac升压为64位,并没有太多的时间去尝试它尚未....

Depending, of course, upon how you've installed and built boost -- this is with my most recent attempt with a full source build. Depending upon how you obtained boost, this may or may not be different. I recently redid the boost on my Mac for 64 bit and haven't had much time to try it yet....

这篇关于添加Boost库为C ++在OS X上的Eclipse项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆