一、编译
1.1、编写一个引入文件
-
# for gcc4:
-
GCCPATH=GCCROOT + '/gcc_only_4.8.2'
-
#GCC4=TOOLCHAIN + '/bin/g++ -std=c++11' #将CC/CXX都设置成g++4,并使用C++11标准
-
GCC4=TGCCPATH + '/bin/g++' #将CC/CXX都设置成g++4,并使用C++11标准
-
GCOV4=GCCPATH + '/bin/gcov'
-
LIB4_DIR=GCCPATH + '/lib64'
-
-
GCC3_COMPATIBLE_FLAGS=' -fpermissive -Wno-literal-suffix -Wno-unused-local-typedefs -Wno-write-strings -std=c++11 -std=gnu++11 '
-
NOFLAGS=GCC3_COMPATIBLE_FLAGS
-
-
GCC4_LDFLAGS='-static-libgcc -static-libstdc++' #静态链接libgcc和libstdc++
-
BIN_LDFLAGS=''
1.2、修改COMAKE文件,引入上面的gcc4属性
-
execfile('GCC4_COMAKE_DEF')
-
CC(GCC4)
-
CXX(GCC4)
1.3、编译错误
-
test.cpp:(.text+0x29): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
-
test.cpp:(.text+0x70): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
-
/tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::record::reset()':
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix6record5resetEv[_ZN5boost3log12v2s_mt_posix6record5resetEv]+0x23): undefined reference to `boost::log::v2s_mt_posix::record_view::public_data::destroy(boost::log::v2s_mt_posix::record_view::public_data const*)'
-
/tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_composite_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex>, boost::log::v2s_mt_posix::sources::features<boost::log::v2s_mt_posix::sources::severity<boost::log::v2s_mt_posix::trivial::severity_level>, void, void, void, void, void, void, void, void, void> >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> const&)':
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix7sources22basic_composite_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEENS2_8featuresINS2_8severityIS6_EEvvvvvvvvvEEE11open_recordINS_9parameter3aux15tagged_argumentINS1_8keywords3tag8severityEKS6_EEEENS1_6recordERKT_[_ZN5boost3log12v2s_mt_posix7sources22basic_composite_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEENS2_8featuresINS2_8severityIS6_EEvvvvvvvvvEEE11open_recordINS_9parameter3aux15tagged_argumentINS1_8keywords3tag8severityEKS6_EEEENS1_6recordERKT_]+0x2d): undefined reference to `boost::log::v2s_mt_posix::core::get_logging_enabled() const'
-
/tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::~record_pump()':
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEED2Ev[_ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEED5Ev]+0x3c): undefined reference to `boost::log::v2s_mt_posix::aux::unhandled_exception_count()'
-
/tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::record_pump(boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>&, boost::log::v2s_mt_posix::record&)':
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEEC2ERS8_RNS1_6recordE[_ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEEC5ERS8_RNS1_6recordE]+0x2f): undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider::allocate_compound(boost::log::v2s_mt_posix::record&)'
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEEC2ERS8_RNS1_6recordE[_ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEEC5ERS8_RNS1_6recordE]+0x3c): undefined reference to `boost::log::v2s_mt_posix::aux::unhandled_exception_count()'
-
/tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::aux::record_pump >::auto_release::~auto_release()':
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEE12auto_releaseD2Ev[_ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEE12auto_releaseD5Ev]+0x17): undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider<char>::release_compound(boost::log::v2s_mt_posix::aux::stream_provider<char>::stream_compound*)'
-
/tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::sources::aux::severity_level::set_value(boost::log::v2s_mt_posix::trivial::severity_level)':
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix7sources3aux14severity_levelINS1_7trivial14severity_levelEE9set_valueES6_[_ZN5boost3log12v2s_mt_posix7sources3aux14severity_levelINS1_7trivial14severity_levelEE9set_valueES6_]+0x10): undefined reference to `boost::log::v2s_mt_posix::sources::aux::get_severity_level()'
-
/tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_logger, boost::log::v2s_mt_posix::sources::multi_thread_model >::open_record_unlocked >(boost::parameter::aux::tagged_argument const&)':
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix7sources12basic_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEEE20open_record_unlockedINS_9parameter3aux15tagged_argumentINS1_8keywords3tag8severityEKS6_EEEENS1_6recordERKT_[_ZN5boost3log12v2s_mt_posix7sources12basic_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEEE20open_record_unlockedINS_9parameter3aux15tagged_argumentINS1_8keywords3tag8severityEKS6_EEEENS1_6recordERKT_]+0x3e): undefined reference to `boost::log::v2s_mt_posix::core::open_record(boost::log::v2s_mt_posix::attribute_set const&)'
-
/tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::sources::basic_logger, boost::log::v2s_mt_posix::sources::multi_thread_model >::push_record_unlocked(boost::rv&)':
-
test.cpp:(.text._ZN5boost3log12v2s_mt_posix7sources12basic_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEEE20push_record_unlockedERNS_2rvINS1_6recordEEE[_ZN5boost3log12v2s_mt_posix7sources12basic_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEEE20push_record_unlockedERNS_2rvINS1_6recordEEE]+0x47): undefined reference to `boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&)
解决方法:引入编译参数
CPPFLAGS -DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK -DBOOST_LOG_DYN_LINK
二、执行
在执行之前,环境变量中export gcc 4.8.2的lib64
export LD_LIBRARY_PATH="gcc_4_8_2_lib64/lib64":$LD_LIBRARY_PATH
阅读(2131) | 评论(0) | 转发(0) |