本文介绍了增强日志记录-获取未解决的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是cmake和boost的新手,因此该问题可能缺少明显的内容:

I am a novice to cmake and boost so this question might be missing something obvious:

我正在Linux(ubuntu)上用cmake构建一个项目,并且试图在该项目中使用boost日志记录.这是我生成Makefile的工作:

I am building a project with cmake on linux (ubuntu) and I am trying to use boost logging in that project. Here is what I do to generate the Makefile:

rm CMakeCache.txt
cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-lboost_log -lboost_log_setup -lpthread -std=c++11" -DCMAKE_SHARED_LINKER_FLAGS="-lboost_log_setup -lboost_log -lpthread" -DCMAKE_MODULE_LINKER_FLAGS="-lboost_log_setup -lboost_log -lpthread" -DCMAKE_CXX_FLAGS="-DBOOST_LOG_DYN_LINK -std=c++11"

编译顺利. (其中一些标志可能会过大,我只需要CMAKE_EXE_LINKER_FLAGS).

Compile goes through fine. (Some of these flags may be overkill -- I should only need the CMAKE_EXE_LINKER_FLAGS).

运行可执行文件时,会得到以下未解决的引用:

When I run the executable, I get the following unresolved reference:

-- ImportError: /home/mranga/gr-msod-sensor/gr-msod_sensor/build/lib/libgnuradio-msod_sensor.so: undefined symbol: _ZN5boost3log11v2_mt_posix3aux25unhandled_exception_countEv

我缺少什么标志?我的增强库已建立,并且LD_LIBRARY_PATH指向正确的位置.

What flags am I missing? My boost library is set up and LD_LIBRARY_PATH points to the right location.

当我使用相同的链接器标记手动构建测试程序时,它会编译并正常运行,因此boost安装正确.希望我不要错过显而易见的地方.

When I manually built a test program using the same linker flags, it compiles and runs fine so boost is installed correctly. I hope I have not missed the obvious.

(从 GNU Radio邮件列表中移出的问题-很抱歉,如果您第二次阅读这篇文章.

(Moved question from the GNU Radio mailing list -- sorry if you are reading this post for a second time).

推荐答案

您似乎正在针对非多线程版本进行链接:

You seem to be linking against the non-multithreaded version:

-lboost_log

,但是运行时链接程序似乎明确地寻找了 multithreaded 变体(该网站上的Boost文档站点):

but the run-time linker seems to explicitely look for the multithreaded variant (the Boost doc site on that):

_ZN5boost3log11v2_mt_posix3aux25unhandled_exception_countEv
                  ^^

因此,我的猜测是您应该尝试与

My guess hence is that you should try linking with

-lboost_log_mt

但这是否正确的问题在很大程度上取决于您的个人项目,使我有可能清楚地回答这个问题.

but the question whether that is right or not depends too much on your individual project to make it possible for me to clearly answer this.

这篇关于增强日志记录-获取未解决的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 00:01
查看更多