gnuradio`ImportError 未定义符号`
gnuradio `ImportError undefined symbol`
我是 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
当您在头文件中声明了一个方法,但您没有实现它时,通常会发生这种情况。例如析构函数或其他东西。
要找出它是哪种方法,您应该拆解未定义的符号 _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi
。
这可以使用 c++filt
工具来完成。例如,
c++filt \ _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi
在您的例子中,这个符号是 GNU Radio 的现有符号,位于 gr-filter
模块中。每个 GNU Radio 模块都会创建一个库,因此为了解决未定义的符号问题,您必须 link 针对所需的库。为此,您必须执行以下步骤:
在模块的 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}
自动生成的变量来正确包含正确的头文件和 link 针对适当的库。
例如:
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。
@manos 更新回答:
从 GNU Radio 3.8+ 开始,CMakeList.txt 文件略有变化。
顶层 CMakeList.txt
需要更改的第一行是:
find_package(Gnuradio "3.8" REQUIRED COMPONENTS blocks analog filter fft)
在lib/CMakeList.txt
中:
target_link_libraries(gnuradio-tempest gnuradio::gnuradio-runtime gnuradio::gnuradio-blocks gnuradio::gnuradio-fft gnuradio::gnuradio-filter Volk::volk)
来源:https://wiki.gnuradio.org/index.php/GNU_Radio_3.8_OOT_Module_Porting_Guide
我是 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
当您在头文件中声明了一个方法,但您没有实现它时,通常会发生这种情况。例如析构函数或其他东西。
要找出它是哪种方法,您应该拆解未定义的符号 _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi
。
这可以使用 c++filt
工具来完成。例如,
c++filt \ _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi
在您的例子中,这个符号是 GNU Radio 的现有符号,位于 gr-filter
模块中。每个 GNU Radio 模块都会创建一个库,因此为了解决未定义的符号问题,您必须 link 针对所需的库。为此,您必须执行以下步骤:
在模块的 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}
自动生成的变量来正确包含正确的头文件和 link 针对适当的库。
例如:
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。
@manos 更新回答:
从 GNU Radio 3.8+ 开始,CMakeList.txt 文件略有变化。
顶层 CMakeList.txt
需要更改的第一行是:
find_package(Gnuradio "3.8" REQUIRED COMPONENTS blocks analog filter fft)
在lib/CMakeList.txt
中:
target_link_libraries(gnuradio-tempest gnuradio::gnuradio-runtime gnuradio::gnuradio-blocks gnuradio::gnuradio-fft gnuradio::gnuradio-filter Volk::volk)
来源:https://wiki.gnuradio.org/index.php/GNU_Radio_3.8_OOT_Module_Porting_Guide