使用qt creator构建boost c ++ 1.48.0

时间:2012-02-25 14:08:52

标签: c++ qt-creator

我一直在努力构建c ++ boost以与qt creator一起工作,但直到现在我得到的都是未定义的引用不同的东西所以这里是我到目前为止所做的: -

  1. 我通过运行bootstrap.bat然后运行bjam
  2. 来构建c ++ boost
  3. 我在我的qt creator .pro项目中包含路径
  4. 像这样

    QT += core gui
    
    TARGET = Heap
    TEMPLATE = app
    
    INCLUDEPATH += C:\boost\boost_1_48_0
    
    LIBS += -L"C:/boost/boost_1_48_0/stage/lib"
    
    SOURCES += \
        main.cpp
    
    HEADERS  += \
        clss.h \
        inputstream.h \
        outputstream.h \
        myexception.h \
        heaptest.h \
        comparable.h \
        heap.h
    
    FORMS    +=
    

    这是我正在测试的示例代码

    #include <boost/regex.hpp>
    #include <iostream>
    #include <string>
    
    int main()
    {
        std::string line;
        boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
    
        while (std::cin)
        {
            std::getline(std::cin, line);
            boost::smatch matches;
            if (boost::regex_match(line, matches, pat))
                std::cout << matches[2] << std::endl;
        }
    }
    

    这是我得到的编译错误

    debug/main.o: In function `cpp_regex_traits_char_layer':
    C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:366: undefined reference to `boost::re_detail::cpp_regex_traits_char_layer<char>::init()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/regex_raw_buffer.hpp:131: undefined reference to `boost::re_detail::raw_storage::resize(unsigned int)'
    debug/main.o: In function `save_state_init':
    C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_non_recursive.hpp:107: undefined reference to `boost::re_detail::get_mem_block()'
    debug/main.o: In function `~save_state_init':
    C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_non_recursive.hpp:115: undefined reference to `boost::re_detail::put_mem_block(void*)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_common.hpp:206: undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_non_recursive.hpp:1117: undefined reference to `boost::re_detail::put_mem_block(void*)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/pattern_except.hpp:75: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/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)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_parser.hpp:219: undefined reference to `boost::regex_error::raise() const'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_parser.hpp:219: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_parser.hpp:219: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:798: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:799: undefined reference to `boost::regex_error::raise() const'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:799: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:799: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:880: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:881: undefined reference to `boost::regex_error::raise() const'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:881: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:881: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:945: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:946: undefined reference to `boost::regex_error::raise() const'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:946: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:946: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:1148: undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:1149: undefined reference to `boost::regex_error::raise() const'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:1149: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:1149: undefined reference to `boost::regex_error::~regex_error()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/perl_matcher_non_recursive.hpp:213: undefined reference to `boost::re_detail::get_mem_block()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:442: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:444: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/basic_regex_creator.hpp:321: undefined reference to `boost::re_detail::raw_storage::insert(unsigned int, unsigned int)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/pending/object_cache.hpp:66: undefined reference to `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/pending/object_cache.hpp:75: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/pending/object_cache.hpp:75: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:633: undefined reference to `boost::re_detail::lookup_default_collate_name(std::string const&)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:675: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:690: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:1059: undefined reference to `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:1062: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
    debug/main.o:C:\Users\Aamer\Desktop\Heap-build-desktop-Qt_4_8_0__4_8_0__Debug/../../../../boost/boost_1_48_0/boost/regex/v4/cpp_regex_traits.hpp:1062: undefined reference to `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
    collect2: ld returned 1 exit status
    mingw32-make.exe[1]: *** [debug/Heap.exe] Error 1
    mingw32-make.exe: *** [debug] Error 2
    16:05:31: The process "C:\Qt\qtcreator-2.4.0\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project Heap (target: Desktop)
    When executing build step 'Make'
    

    我如何才能构建它?

1 个答案:

答案 0 :(得分:1)

尝试将LIBS += -L"C:/boost/boost_1_48_0/stage/lib"行更改为:

LIBS += -L"C:/boost/boost_1_48_0/stage/lib" -lboost_regex

(将boost_regex替换为构建库的实际名称(可能类似于boost_regex-mgw44-mt-1_48))