boost:mingw:windows 10:未定义的引用

时间:2016-10-23 03:41:40

标签: c++ eclipse boost mingw c++14

如何将升压记录添加到c ++项目中?

我第一次尝试将Boost添加到我的家庭开发环境中。我现在想做的就是能够使用boost的日志记录实现来记录我当前正在打印到stdout到文件的一些错误。我开始使用lambda示例代码进行构建,现在我尝试添加日志记录示例代码,但我收到此错误:

C:\boost_1_62_0/libs/log/src/text_file_backend.cpp:597: undefined reference to `boost::filesystem::absolute(boost::filesystem::path const&, boost::filesystem::path const&)'

我的代码是:

/* for logging */
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/utility/setup/file.hpp>
namespace logging = boost::log;

void init(){
    logging::add_file_log("sample.log");

    logging::core::get()->set_filter
    (
        logging::trivial::severity >= logging::trivial::info
    );
}

如果我发表评论&#39; logging :: add_file_log(&#34; sample.log&#34;);&#39;它建立得很好

完整版输出:

 22:15:12 **** Rebuild of configuration Debug for project foo ****
 Info: Internal Builder is used for build
 g++ -std=c++1y "-IC:\\boost_1_62_0" "-IC:\\boost_1_62_0\\stage\\lib" -O0 -g3 -Wall -c -fmessage-length=0 -DBOOST_LOG_USE_NATIVE_SYSLOG -lboost_filesystem -lboost_system -lboost_thread-mt -lboost_log_setup -lboost_log -o foo_main.o "..\\foo_main.cpp" 
 g++ -static-libgcc -static-libstdc++ -static "-LC:\\boost_1_62_0\\stage\\lib" -lboost_regex-mgw53-mt-d-1_62 -LC:/boost_1_62_0/stage/lib/ -lboost_regex-mgw53-mt-d-1_62 -o foo.exe foo_main.o -lboost_atomic-mgw53-mt-d-1_62 -lboost_chrono-mgw53-mt-d-1_62 -lboost_container-mgw53-mt-d-1_62 -lboost_context-mgw53-mt-d-1_62 -lboost_coroutine-mgw53-mt-d-1_62 -lboost_date_time-mgw53-mt-d-1_62 -lboost_exception-mgw53-mt-d-1_62 -lboost_filesystem-mgw53-mt-d-1_62 -lboost_graph-mgw53-mt-d-1_62 -lboost_iostreams-mgw53-mt-d-1_62 -lboost_locale-mgw53-mt-d-1_62 -lboost_log_setup-mgw53-mt-d-1_62 -lboost_log-mgw53-mt-d-1_62 -lboost_iostreams-mgw53-mt-d-1_62 -lboost_math_tr1f-mgw53-mt-d-1_62 -lboost_math_tr1l-mgw53-mt-d-1_62 -lboost_math_tr1-mgw53-mt-d-1_62 -lboost_prg_exec_monitor-mgw53-mt-d-1_62 -lboost_program_options-mgw53-mt-d-1_62 -lboost_system-mgw53-mt-d-1_62 -lboost_random-mgw53-mt-d-1_62 -lboost_serialization-mgw53-mt-d-1_62 -lboost_signals-mgw53-mt-d-1_62 -lboost_system-mgw53-mt-d-1_62 -lboost_test_exec_monitor-mgw53-mt-d-1_62 -lboost_thread-mgw53-mt-d-1_62 -lboost_timer-mgw53-mt-d-1_62 -lboost_type_erasure-mgw53-mt-d-1_62 -lboost_unit_test_framework-mgw53-mt-d-1_62 -lboost_wave-mgw53-mt-d-1_62 -lboost_wserialization-mgw53-mt-d-1_62 
 C:\boost_1_62_0\stage\lib\libboost_log-mgw53-mt-d-1_62.a(text_file_backend.o): In function `make_absolute':
 C:\boost_1_62_0/libs/log/src/text_file_backend.cpp:597: undefined reference to `boost::filesystem::absolute(boost::filesystem::path const&, boost::filesystem::path const&)'
 C:\boost_1_62_0\stage\lib\libboost_log-mgw53-mt-d-1_62.a(text_file_backend.o): In function `ZN5boost3log10v2s_mt_nt55sinks17text_file_backend30set_file_name_pattern_internalERKNS_10filesystem4pathE':
 C:\boost_1_62_0/libs/log/src/text_file_backend.cpp:1264: undefined reference to `boost::filesystem::absolute(boost::filesystem::path const&, boost::filesystem::path const&)'
 C:\boost_1_62_0\stage\lib\libboost_log-mgw53-mt-d-1_62.a(text_file_backend.o): In function `ZN5boost10filesystem6existsERKNS0_4pathE':
 ...enter code here
 C:\boost_1_62_0/./boost/filesystem/operations.hpp:872: undefined reference to `boost::filesystem::detail::dir_itr_close(void*&)'
 C:\boost_1_62_0\stage\lib\libboost_log-mgw53-mt-d-1_62.a(text_file_backend.o): In function `ZN5boost10filesystem18directory_iteratorC1ERKNS0_4pathE':
 C:\boost_1_62_0/./boost/filesystem/operations.hpp:903: undefined reference to `boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)'
 C:\boost_1_62_0\stage\lib\libboost_log-mgw53-mt-d-1_62.a(text_file_backend.o): In function `ZN5boost10filesystem18directory_iterator9incrementEv':
 C:\boost_1_62_0/./boost/filesystem/operations.hpp:939: undefined reference to `boost::filesystem::detail::directory_iterator_increment(boost::filesystem::directory_iterator&, boost::system::error_code*)'
 C:\boost_1_62_0\stage\lib\libboost_log-mgw53-mt-d-1_62.a(text_file_backend.o): In function `ZN5boost10filesystem4pathaSINS0_15directory_entryEEENS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIT_E4typeEEERS1_E4typeERKS8_':
 C:\boost_1_62_0/./boost/filesystem/path.hpp:202: undefined reference to `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&)'
 collect2.exe: error: ld returned 1 exit status

 22:15:18 Build Finished (took 5s.607ms)

我在运行Eclipse Version:Neon.1a Release(4.6.1)的Windows 10机器上执行此操作。我使用的是mingw编译器,gcc(GCC)版本5.3.0。

我使用此命令构建了我的boost库:

b2 toolset=gcc cxxflags=-std=c++1y -a

我的boost_filesystem库的绝对路径是:

C:\boost_1_62_0\stage\lib\libboost_filesystem-mgw53-mt-d-1_62.a

0 个答案:

没有答案