参考:
https://github.com/gnuradio/gnuradio/issues/1608
https://github.com/gnuradio/gnuradio/pull/1614
两种解决方法
https://github.com/gnuradio/gnuradio/pull/1614/commits/854a692871f51f97384dabcea8435cf87a70ce4
https://github.com/vamsi765/gr-testinggnuradio/commit/c204fc73a1d040539298f776d2fcd345fcce6394
https://github.com/gnuradio/gnuradio/blob/maint/CMakeLists.txt
https://github.com/gnuradio/gnuradio/pull/1614/files
https://github.com/gnuradio/gnuradio/blob/maint/docs/doxygen/other/logger.dox
大概意思:
为了在基于gr_modtool模板模块,需要进行一些CMake修改。
没有这些更改,日志记录将被禁用。
OOT模块顶层CMakeLists.Texts文件必须包含GrMiscUtils.cmake模块,以及GrMiscUtils提供的GR_LOGGING()函数必须从同一顶级CMakeLists.txt文件调用。这会设置适当的构建环境,然后在该过程中尝试使用FindLog4Cpp.cmake模块查找log4cpp软件包。
该模块未包含在gr_modtool的模块中,但属于GNU Radio代码库,可以直接复制到cmake/Modules/OOT模块的目录。
完成这些CMake更改后,GR日志记录界面将起作用如本页所述。
(1)修改项目模块文件夹下的CMakeLists.txt
找到
########################################################################
# Compiler specific setup
########################################################################
在这三行下面添加
include(GrMiscUtils)
(2)OOT模块顶层CMakeLists.Texts文件:调用GrMiscUtils提供的GR_LOGGING()函数
- 还是刚刚那个CMakeLists.txt:
其实就是在include(GrMiscUtils)后面再添加
GR_LOGGING()
(3)FindLog4Cpp.cmake模块加入cmake/Modules/OOT模块的目录
在cmake/Modules/OOT下新建一个记事本,重命名为FindLog4Cpp.cmake
内容为:
# - Find Log4cpp
# Find the native LOG4CPP includes and library
#
# LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc.
# LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP.
# LOG4CPP_FOUND - True if LOG4CPP found.
if (LOG4CPP_INCLUDE_DIR)
# Already in cache, be silent
set(LOG4CPP_FIND_QUIETLY TRUE)
endif ()
find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh
/opt/local/include
/usr/local/include
/usr/include
)
set(LOG4CPP_NAMES log4cpp)
find_library(LOG4CPP_LIBRARY
NAMES ${LOG4CPP_NAMES}
PATHS /usr/lib /usr/local/lib /opt/local/lib
)
if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY)
set(LOG4CPP_FOUND TRUE)
set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} CACHE INTERNAL "" FORCE)
set(LOG4CPP_INCLUDE_DIRS ${LOG4CPP_INCLUDE_DIR} CACHE INTERNAL "" FORCE)
else ()
set(LOG4CPP_FOUND FALSE CACHE INTERNAL "" FORCE)
set(LOG4CPP_LIBRARY "" CACHE INTERNAL "" FORCE)
set(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE)
set(LOG4CPP_INCLUDE_DIR "" CACHE INTERNAL "" FORCE)
set(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE)
endif ()
if (LOG4CPP_FOUND)
if (NOT LOG4CPP_FIND_QUIETLY)
message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}")
endif ()
else ()
if (LOG4CPP_FIND_REQUIRED)
message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.")
message(FATAL_ERROR "Could NOT find LOG4CPP library")
endif ()
endif ()
mark_as_advanced(
LOG4CPP_LIBRARIES
LOG4CPP_INCLUDE_DIRS
)
参考内容为:https://github.com/gnuradio/gnuradio/commit/854a692871f51f97384dabcea8435cf87a70ce41。
如果上述方法还不行,就按照
https://github.com/gnuradio/gnuradio/commit/854a692871f51f97384dabcea8435cf87a70ce41
的方法尝试一下,反正我两种方法都试了,就可以输出信息了!