gpt4 book ai didi

python - gnuradio `ImportError undefined symbol`

转载 作者:太空狗 更新时间:2023-10-29 20:24:16 25 4
gpt4 key购买 nike

我是 GNU Radio 和 python 的新手。我正在尝试编写一个相关 block ,在我的代码中某处我使用了 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

最佳答案

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

要找出它是哪种方法,您应该分解 undefined symbol _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi

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

c++filt\_ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi

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

在模块的 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})

有关更多信息,请参阅 here .

关于python - gnuradio `ImportError undefined symbol`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28859517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com