3

我是 GNU Radio 和 python 的新手。我正在尝试编写一个相关块,在我的代码中某处我使用 fft 过滤器:

gr::filter::kernel::fft_filter_ccc  *d_filter;
d_filter = new gr::filter::kernel::fft_filter_ccc(1, x_vector);
d_filter->filter(noutput_items,in_y,out);

我跑

cmake ../
make 

它完全符合要求,但是当我尝试时

make test

我会收到这个错误:

 Traceback (most recent call last):
2:   File "/home/mohammad/projects/FD/implementation_tests/oot_modules/gr-full_duplex/python/qa_fd_correlation_cc.py", line 25, in <module>
2:     import full_duplex_swig as full_duplex
2:   File "/home/mohammad/projects/FD/implementation_tests/oot_modules/gr-full_duplex/build/swig/full_duplex_swig.py", line 28, in <module>
2:     _full_duplex_swig = swig_import_helper()
2:   File "/home/mohammad/projects/FD/implementation_tests/oot_modules/gr-full_duplex/build/swig/full_duplex_swig.py", line 24, in swig_import_helper
2:     _mod = imp.load_module('_full_duplex_swig', fp, pathname, description)
2: ImportError: /home/mohammad/projects/FD/implementation_tests/oot_modules/gr-full_duplex/build/lib/libgnuradio-full_duplex.so: undefined symbol: _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi
1/1 Test #2: qa_fd_correlation_cc .............***Failed    1.30 sec
4

1 回答 1

6

当您在头文件中声明了一个方法但您没有实现它时,通常会发生这种情况。例如析构函数或其他东西。

要找出它是哪种方法,您应该对未定义的符号进行解码_ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi

这可以使用该c++filt工具来完成。例如,

c++filt \ _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi

在您的情况下,此符号是位于gr-filter模块中的 GNU Radio 的现有符号。每个 GNU Radio 模块都会创建一个库,因此为了解决未定义符号问题,您必须链接到所需的库。为此,您必须执行以下步骤:

CMakeLists.txt您的模块文件中,指定您依赖的 GNU Radio 的哪些组件。在您的情况下,FILTER组件。

set(GR_REQUIRED_COMPONENTS RUNTIME FILTER)
find_package(Gnuradio "3.7.0" REQUIRED)

可以插入更多依赖项,例如:

set(GR_REQUIRED_COMPONENTS RUNTIME FILTER DIGITAL)

之后,您可以使用${GNURADIO_ALL_INCLUDE_DIRS}${GNURADIO_ALL_LIBRARIES}自动生成的变量来正确包含正确的头文件并链接到相应的库。例如:

include_directories(
    ${CMAKE_SOURCE_DIR}/lib
    ${CMAKE_SOURCE_DIR}/include
    ${CMAKE_BINARY_DIR}/lib
    ${CMAKE_BINARY_DIR}/include
    ${Boost_INCLUDE_DIRS}
    ${CPPUNIT_INCLUDE_DIRS}
    ${GNURADIO_RUNTIME_INCLUDE_DIRS}
    ${GNURADIO_ALL_INCLUDE_DIRS}
)

target_link_libraries(gnuradio-howto
                      ${Boost_LIBRARIES}
                      ${GNURADIO_RUNTIME_LIBRARIES}
                      ${GNURADIO_ALL_LIBRARIES})

有关更多信息,请参阅此处

于 2015-03-05T00:32:22.663 回答