天天看點

gnuradio在終端輸出無法輸出gr::log INFO資訊問題

參考:

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

的方法嘗試一下,反正我兩種方法都試了,就可以輸出資訊了!

繼續閱讀