链接QT 5.12 Mingw中的所有Boost库

时间:2018-12-27 15:49:25

标签: c++ qt boost


我正在学习boost并测试一些示例,因此我将QT项目中的boost库与MinGW编译器链接在一起,并且我想链接所有库,以便可以使用从文件系统到asio的任何内容,并可以使用使用许多类的不同示例。 /> 这是我的.pro文件,我链接了Boost库

INCLUDEPATH += C:/boost_1_66_0

LIBS += -LC:/boost_1_66_0/stage/lib     -llibboost_atomic-mgw63-mt-d-x32-1_66\
        -llibboost_atomic-mgw63-mt-x32-1_66\
        -llibboost_chrono-mgw63-mt-d-x32-1_66\
        -llibboost_chrono-mgw63-mt-x32-1_66\
        -llibboost_container-mgw63-mt-d-x32-1_66\
        -llibboost_container-mgw63-mt-x32-1_66\
        -llibboost_context-mgw63-mt-d-x32-1_66\
        -llibboost_context-mgw63-mt-x32-1_66\
        -llibboost_coroutine-mgw63-mt-d-x32-1_66\
        -llibboost_coroutine-mgw63-mt-x32-1_66\
        -llibboost_date_time-mgw63-mt-d-x32-1_66\
        -llibboost_date_time-mgw63-mt-x32-1_66\
        -llibboost_exception-mgw63-mt-d-x32-1_66\
        -llibboost_exception-mgw63-mt-x32-1_66\
        -llibboost_filesystem-mgw63-mt-d-x32-1_66\
        -llibboost_filesystem-mgw63-mt-x32-1_66\
        -llibboost_graph-mgw63-mt-d-x32-1_66\
        -llibboost_graph-mgw63-mt-x32-1_66\
        -llibboost_iostreams-mgw63-mt-d-x32-1_66\
        -llibboost_iostreams-mgw63-mt-x32-1_66\
        -llibboost_locale-mgw63-mt-d-x32-1_66\
        -llibboost_locale-mgw63-mt-x32-1_66\
        -llibboost_log-mgw63-mt-d-x32-1_66\
        -llibboost_log-mgw63-mt-x32-1_66\
        -llibboost_log_setup-mgw63-mt-d-x32-1_66\
        -llibboost_log_setup-mgw63-mt-x32-1_66\
        -llibboost_math_c99-mgw63-mt-d-x32-1_66\
        -llibboost_math_c99-mgw63-mt-x32-1_66\
        -llibboost_math_c99f-mgw63-mt-d-x32-1_66\
        -llibboost_math_c99f-mgw63-mt-x32-1_66\
        -llibboost_math_c99l-mgw63-mt-d-x32-1_66\
        -llibboost_math_c99l-mgw63-mt-x32-1_66\
        -llibboost_math_tr1-mgw63-mt-d-x32-1_66\
        -llibboost_math_tr1-mgw63-mt-x32-1_66\
        -llibboost_math_tr1f-mgw63-mt-d-x32-1_66\
        -llibboost_math_tr1f-mgw63-mt-x32-1_66\
        -llibboost_math_tr1l-mgw63-mt-d-x32-1_66\
        -llibboost_math_tr1l-mgw63-mt-x32-1_66\
        -llibboost_prg_exec_monitor-mgw63-mt-d-x32-1_66\
        -llibboost_prg_exec_monitor-mgw63-mt-x32-1_66\
        -llibboost_program_options-mgw63-mt-d-x32-1_66\
        -llibboost_program_options-mgw63-mt-x32-1_66\
        -llibboost_random-mgw63-mt-d-x32-1_66\
        -llibboost_random-mgw63-mt-x32-1_66\
        -llibboost_regex-mgw63-mt-d-x32-1_66\
        -llibboost_regex-mgw63-mt-x32-1_66\
        -llibboost_serialization-mgw63-mt-d-x32-1_66\
        -llibboost_serialization-mgw63-mt-x32-1_66\
        -llibboost_signals-mgw63-mt-d-x32-1_66\
        -llibboost_signals-mgw63-mt-x32-1_66\
        -llibboost_stacktrace_basic-mgw63-mt-d-x32-1_66\
        -llibboost_stacktrace_basic-mgw63-mt-x32-1_66\
        -llibboost_stacktrace_noop-mgw63-mt-d-x32-1_66\
        -llibboost_stacktrace_noop-mgw63-mt-x32-1_66\
        -llibboost_system-mgw63-mt-d-x32-1_66\
        -llibboost_system-mgw63-mt-x32-1_66\
        -llibboost_test_exec_monitor-mgw63-mt-d-x32-1_66\
        -llibboost_test_exec_monitor-mgw63-mt-x32-1_66\
        -llibboost_thread-mgw63-mt-d-x32-1_66\
        -llibboost_thread-mgw63-mt-x32-1_66\
        -llibboost_timer-mgw63-mt-d-x32-1_66\
        -llibboost_timer-mgw63-mt-x32-1_66\
        -llibboost_type_erasure-mgw63-mt-d-x32-1_66\
        -llibboost_type_erasure-mgw63-mt-x32-1_66\
        -llibboost_unit_test_framework-mgw63-mt-d-x32-1_66\
        -llibboost_unit_test_framework-mgw63-mt-x32-1_66\
        -llibboost_wave-mgw63-mt-d-x32-1_66\
        -llibboost_wave-mgw63-mt-x32-1_66\
        -llibboost_wserialization-mgw63-mt-d-x32-1_66\
        -llibboost_wserialization-mgw63-mt-x32-1_66\

我转到boost lib文件夹并如上所述添加所有库,我现在开始测试一些功能,尽管我链接了所有库并且在Release模式下使用它,但我仍未对某些功能进行引用,这是我的主要任务我在其中使用Boost Archive

#include <fstream>
#include <ios>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <locale>
#include <codecvt>
#include <cstring>

#include <boost/archive/text_oarchive.hpp>
using namespace boost::archive;

using namespace std;

int main(int argc, char *argv[])
{ 
    ofstream out("D:/a.txt");
    text_oarchive oa(out);

    int a = INT_MAX;
    oa << a;
    out.close();


    return 0;
}

这是我得到的错误

release/main.o:main.cpp:(.text.startup+0xf1): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::_exception_code, char const*, char const*)'
release/main.o:main.cpp:(.text$_ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_14object_id_typeE[__ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_14object_id_typeE]+0x69): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::_exception_code, char const*, char const*)'
release/main.o:main.cpp:(.text$_ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_21object_reference_typeE[__ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_21object_reference_typeE]+0x62): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::_exception_code, char const*, char const*)'
release/main.o:main.cpp:(.text$_ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_13class_id_typeE[__ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_13class_id_typeE]+0x63): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::_exception_code, char const*, char const*)'
release/main.o:main.cpp:(.text$_ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_23class_id_reference_typeE[__ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_23class_id_reference_typeE]+0x63): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::_exception_code, char const*, char const*)'
release/main.o:main.cpp:(.text$_ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_13tracking_typeE[__ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE5vsaveENS0_13tracking_typeE]+0x63): more undefined references to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::_exception_code, char const*, char const*)' follow
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [Makefile.Release:63: release/Normal2.exe] Error 1
mingw32-make: *** [Makefile:36: release] Error 2
mingw32-make[1]: Leaving directory 'D:/WorkPlace/CppProject/cpp/build-Normal2-Desktop_QT_5_12_0_MinGW_32_bit-Release'
17:41:30: The process "C:\Qt\Qt5.12.0\Tools\mingw730_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project Normal2 (kit: Desktop QT 5.12.0 MinGW 32-bit)
When executing step "Make"
17:41:30: Elapsed time: 00:04.

那么我给我这些错误带来了什么错误,我已经链接了所有库并将它们添加到我的项目中,但是我还没有测试更多的示例,所以我不知道如果我使用了我是否还会遇到一些错误不同的班级。
Iam使用此网站来了解有关Boost库here的更多信息,因此我将通过不同的示例进行测试,并且需要链接所有Boost库。
更新
现在,这是我的.pro文件,我从一开始就删除了lib,我删除了调试库,仅使用发布版本,这是我的.pro文件

LIBS += -LC:/boost_1_66_0/stage/lib     -lboost_atomic-mgw63-mt-x32-1_66\
        -lboost_chrono-mgw63-mt-x32-1_66\
        -lboost_container-mgw63-mt-x32-1_66\
        -lboost_context-mgw63-mt-x32-1_66\
        -lboost_coroutine-mgw63-mt-x32-1_66\
        -lboost_date_time-mgw63-mt-x32-1_66\
        -lboost_exception-mgw63-mt-x32-1_66\
        -lboost_filesystem-mgw63-mt-x32-1_66\
        -lboost_graph-mgw63-mt-x32-1_66\
        -lboost_iostreams-mgw63-mt-x32-1_66\
        -lboost_locale-mgw63-mt-x32-1_66\
        -lboost_log-mgw63-mt-x32-1_66\
        -lboost_log_setup-mgw63-mt-x32-1_66\
        -lboost_math_c99-mgw63-mt-x32-1_66\
        -lboost_math_c99f-mgw63-mt-x32-1_66\
        -lboost_math_c99l-mgw63-mt-x32-1_66\
        -lboost_math_tr1-mgw63-mt-x32-1_66\
        -lboost_math_tr1f-mgw63-mt-x32-1_66\
        -lboost_math_tr1l-mgw63-mt-x32-1_66\
        -lboost_prg_exec_monitor-mgw63-mt-x32-1_66\
        -lboost_program_options-mgw63-mt-x32-1_66\
        -lboost_random-mgw63-mt-x32-1_66\
        -lboost_regex-mgw63-mt-x32-1_66\
        -lboost_serialization-mgw63-mt-x32-1_66\
        -lboost_signals-mgw63-mt-x32-1_66\
        -lboost_stacktrace_basic-mgw63-mt-x32-1_66\
        -lboost_stacktrace_noop-mgw63-mt-x32-1_66\
        -lboost_system-mgw63-mt-x32-1_66\
        -lboost_test_exec_monitor-mgw63-mt-x32-1_66\
        -lboost_thread-mgw63-mt-x32-1_66\
        -lboost_timer-mgw63-mt-x32-1_66\
        -lboost_type_erasure-mgw63-mt-x32-1_66\
        -lboost_unit_test_framework-mgw63-mt-x32-1_66\
        -lboost_wave-mgw63-mt-x32-1_66\
        -lboost_wserialization-mgw63-mt-x32-1_66\

但是仍然存在相同的问题,如果顺序与我需要使该示例工作的顺序有关,又有一种方法可以一次按正确的顺序添加它们,那么效果会更好。

谢谢。

0 个答案:

没有答案