且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

链接 boost 日志教程时的链接器错误(未定义的参考)

更新时间:2023-11-10 17:32:04

只需添加一行

#define BOOST_LOG_DYN_LINK 1

作为boosttest.cc的第一行.

或者,您可以将 -DBOOST_LOG_DYN_LINK 添加到您的编译步骤(不是您在问题中发布的链接步骤):

Alternatively, you can add -DBOOST_LOG_DYN_LINK to you compilation step (not the linking step, as you posted in the question):

g++ -std=c++11 -Wall -pedantic -g -O0 -DBOOST_LOG_DYN_LINK  -c boosttest.cc
g++  boosttest.o -lpthread -lboost_log -o boosttest