Chinaunix首页 | 论坛 | 博客
  • 博客访问: 138105
  • 博文数量: 28
  • 博客积分: 250
  • 博客等级: 二等列兵
  • 技术积分: 270
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-30 15:13
文章分类
文章存档

2017年(1)

2016年(8)

2015年(7)

2012年(12)

我的朋友

分类: C/C++

2016-09-06 14:46:11

一、编译
1.1、编写一个引入文件

点击(此处)折叠或打开

  1. # for gcc4:
  2. GCCPATH=GCCROOT + '/gcc_only_4.8.2'
  3. #GCC4=TOOLCHAIN + '/bin/g++ -std=c++11' #将CC/CXX都设置成g++4,并使用C++11标准
  4. GCC4=TGCCPATH + '/bin/g++' #将CC/CXX都设置成g++4,并使用C++11标准
  5. GCOV4=GCCPATH + '/bin/gcov'
  6. LIB4_DIR=GCCPATH + '/lib64'

  7. GCC3_COMPATIBLE_FLAGS=' -fpermissive -Wno-literal-suffix -Wno-unused-local-typedefs -Wno-write-strings -std=c++11 -std=gnu++11 '
  8. NOFLAGS=GCC3_COMPATIBLE_FLAGS

  9. GCC4_LDFLAGS='-static-libgcc -static-libstdc++' #静态链接libgcc和libstdc++
  10. BIN_LDFLAGS=''
1.2、修改COMAKE文件,引入上面的gcc4属性

点击(此处)折叠或打开

  1. execfile('GCC4_COMAKE_DEF')
  2. CC(GCC4)
  3. CXX(GCC4)
1.3、编译错误

点击(此处)折叠或打开

  1. test.cpp:(.text+0x29): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
  2. test.cpp:(.text+0x70): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
  3. /tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::record::reset()':
  4. 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*)'
  5. /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&)':
  6. 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'
  7. /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()':
  8. 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()'
  9. /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&)':
  10. 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&)'
  11. 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()'
  12. /tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::aux::record_pump >::auto_release::~auto_release()':
  13. 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*)'
  14. /tmp/ccDUZ2gm.o: In function `boost::log::v2s_mt_posix::sources::aux::severity_level::set_value(boost::log::v2s_mt_posix::trivial::severity_level)':
  15. 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()'
  16. /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&)':
  17. 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&)'
  18. /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&)':
  19. 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) |
给主人留下些什么吧!~~