开发者

Setting up environment for C++/Boost libs (netbeans or eclipse)

开发者 https://www.devze.com 2023-03-06 11:45 出处:网络
I\'ve followed so many tutorials now and I can\'t get this basic, fundamental thing right. I\'m getting started with C++ and moving on from the standard intro stuff (after two books) and I\'m working

I've followed so many tutorials now and I can't get this basic, fundamental thing right. I'm getting started with C++ and moving on from the standard intro stuff (after two books) and I'm working through "Beyond the C++ Standard Library ~ An Introduction to Boost" but I can't seem to get either Netbeans or Eclipse to compile and run my boost projects.

I've looked at How to configure Boost with Netbeans 6.9 on Ubuntu http://www.fischerlaender.net/development/using-boost-c-libraries-with-gcc-g-under-windows and a few others but I can't seem to get it right. In Netbeans (my preference) I've gotten as far as specifying the additional include directories, and netbeans recognizes it to the extent where it provides auto completion when including anything from boost/* e.g #include is fine but when I try to compile it I get:

mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++.exe    -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
main.cpp:7:27: fatal error: boost/regex.hpp: No such file or directory
compilation terminated.
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost'
make[1]: Leaving directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost'

but I don't get why the file cannot be found... any help is much appreciated. UPDATE Set the include directory under Properties->C++ Compiler and chosen 32 bits as the architecture. The compile error's changed to :

"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost'
"/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/helloboost.exe
make[2]: Entering directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++.exe -m32   -c -g -I/C/Program\ Files\ \(x86\)/boost/boost_1_46_1 -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-Windows
g++.exe -m32    -o dist/Debug/MinGW-Windows/helloboost build/Debug/MinGW-Windows/main.o  
build/Debug/MinGW-Windows/main.o: In function `cpp_regex_traits_char_layer':
c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:366: undefined reference to `boost::re_detail::cpp_regex_traits_char_layer<char>::init()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/regex_raw_buffer.hpp:131: undefined reference to `boost::re_detail::raw_storage::resize(unsigned int)'
build/Debug/MinGW-Windows/main.o: In function `save_state_init':
c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_non_recursive.hpp:107: undefined reference to `boost::re_detail::get_mem_block()'
build/Debug/MinGW-Windows/main.o: In function `~save_state_init':
c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_non_recursive.hpp:115: undefined reference to `boost::re_detail::put_mem_block(void*)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_common.hpp:206: undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_non_recursive.hpp:1117: undefined reference to `boost::re_detail::put_mem_block(void*)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/pattern_except.hpp:75: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_parser.hpp:218: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_parser.hpp:219: undefined reference to `boost::regex_error::raise() const'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_parser.hpp:218: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_parser.hpp:218: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:795: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:796: undefined reference to `boost::regex_error::raise() const'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:795: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:877: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:878: undefined reference to `boost::regex_error::raise() const'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:877: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:795: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:877: undefined reference to `boost::regex_error::~regex_error()'
make[2]: Leaving directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:942: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
make[1]: Leaving directory `/c/Users/Courtney/Documents/Projects/Desktop/HelloBoost'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:943: undefined reference to `boost::regex_error::raise() const'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:942: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:942: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:1133: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:1134: undefined reference to `boost::regex_error::raise() const'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:1133: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:1133: undefined reference to `boost::regex_error::~regex_error()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/perl_matcher_non_recursive.hpp:213: undefined reference to `boost::re_detail::get_mem_block()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:442: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:444: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/basic_regex_creator.hpp:320: undefined reference to `boost::re_detail::raw_storage::insert(unsigned int, unsigned int)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/pending/object_cache.hpp:66: undefined reference to `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/pending/object_cache.hpp:66: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/pending/object_cache.hpp:66: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:625: undefined reference to `boost::re_detail::lookup_default_collate_name(std::string const&)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:667: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:682: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
build/Debug/MinGW-Windows/main.o:c:/Prog开发者_如何学Cram Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:1051: undefined reference to `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:1051: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
build/Debug/MinGW-Windows/main.o:c:/Program Files (x86)/boost/boost_1_46_1/boost/regex/v4/cpp_regex_traits.hpp:1051: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/helloboost.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 31s)


g++.exe    -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp

That compilation command does not have necessary -I switch. It seems like the include directory was set in a wrong place. Maybe it was only set for autocompletion, but not compilation?

0

精彩评论

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