gnuradio`ImportError undefined symbol`

时间:2015-03-04 16:21:36

标签: python c++ gnuradio

我是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

1 个答案:

答案 0 :(得分: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}自动生成的变量来正确包含正确的头文件并链接到相应的库。 E.g:

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})

有关详细信息,请参阅here