开发者

Adding Boost to Eclipse for C++ - include path problems

开发者 https://www.devze.com 2023-02-26 04:39 出处:网络
I\'m experienced with Windows development, GNU, and C++, but I\'m new to Eclipse. I\'m trying to add Boost to my Eclipse project which is building on Windows (but for an embedded processor) with the G

I'm experienced with Windows development, GNU, and C++, but I'm new to Eclipse. I'm trying to add Boost to my Eclipse project which is building on Windows (but for an embedded processor) with the GNU toolchain.

I have added Boost here: C:\altera\10.1\quartus\bin\cygwin\usr\include\boost_1_46_1

I have added that directory to my Eclipse include path (project Properties | C/C++ General | Paths and Symbols | Includes | GNU C++), where I see C:\altera\10.1\quartus\bin\cygwin\usr\include shows up as a built-in directory.

I can browse these directories and files under the Eclipse Project Explorer and open them up from the Outline. Yet, when I include them it doesn't work.

My code contains this:

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

The Eclipse generated build string looks like this (note the lack of the 开发者_JAVA百科two directories mentioned above):

nios2-elf-gcc -xc++ -MP -MMD -c -I../NiosIITestSpin_bsp/UCOSII/inc -I../NiosIITestSpin_bsp/HAL/inc -I../NiosIITestSpin_bsp -I../NiosIITestSpin_bsp/drivers/inc  -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_INSTRUCTION_EMULATION -D__ucosii__      -O0 -g -Wall   -EL -mhw-div -mcustom-fpu-cfg=60-1 -mhw-mul -mhw-mulx  -o obj/Test.o Test.cpp

Test.cpp:12:41: warning: boost/property_tree/ptree.hpp: No such file or directory
Test.cpp:13:46: warning: boost/property_tree/xml_parser.hpp: No such file or directory

I clean, regen makefiles, and rebuild, but I can't get the compiler to see this new include directory.

If I change the code to include the full path, it gets a step further in that it can open those files, but it still can't open Boost files that they include.

I have googled and searched StackOverflow and Eclipse to no avail. There are lots of similar problems, but nothing that is quite the same or has worked for me.

Any ideas?


Try it like this:

#include "boost/property_tree/ptree.hpp"
#include "boost/property_tree/xml_parser.hpp"

#include <> and #include "" are handled differently. The first one means a "system" include path while the second one is for a "user" include path.


I had the same problem and jumped through the same hoops (even tried the "" instead of the <>). The solution turned out to be really kind of silly. It is a windows machine; remember that they handle file paths differently.

From the original post:

C:\altera\10.1\quartus\bin\cygwin\usr\include\boost_1_46_1

Change the slash direction so that it reads:

c:/altera/10.1/quartus/bin/cygwin/usr/include/boost_1_46_1

(Edit the include path; under project Properties | C/C++ General | Paths and Symbols | Includes | GNU C++)

This solved the problem for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消