3

I'm new to GNU Radio and python. I'm trying to write a correlation block, somewhere in my code I use fft filter:

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

I run

cmake ../
make 

and it complies perfectly fine, but when i try

make test

I'll get this error:

 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

2 Answers 2

6

This often happens when you have declared a method at the header file, but you do not implement it. For example a destructor or something else.

To find out which method it is you should demangle the undefined symbol _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi.

This can be done using the c++filt tool. For example,

c++filt \ _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi

In your case this symbol is an existing symbol of the GNU Radio, located in the gr-filter module. Each GNU Radio module creates a library, so in order to resolve the undefined symbol issue you have to link against the required library. To accomplish this you have to do the following steps:

At the CMakeLists.txt file of your module, specify on which components of GNU Radio you depend. In your case the FILTER component.

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

Further dependencies can be inserted, eg:

set(GR_REQUIRED_COMPONENTS RUNTIME FILTER DIGITAL)

After that you can use the ${GNURADIO_ALL_INCLUDE_DIRS} and ${GNURADIO_ALL_LIBRARIES} auto generated variables to properly include the proper header files and link against the appropriate 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})

For more info refer here.

4
  • this is the output: gr::filter::kernel::fft_filter_ccc::fft_filter_ccc(int, std::vector<std::complex<float>, std::allocator<std::complex<float> > > const&, int) what should I do with it?
    – Moe
    Mar 5, 2015 at 6:40
  • it's fft_filter_ccc(int,vector,float*,int) in the outptut of c++filt, but in my code its fft_filter_ccc(int,vector) , and the documation says fft_ftiler_ccc(int,vector,int=1)
    – Moe
    Mar 5, 2015 at 6:47
  • @Mohammad, I think that your problem lies at the way you build the module. See my updated answer. Hope that will help you.
    – Manos
    Mar 5, 2015 at 12:34
  • thank you very much :-) the problem is now solve, It's interesting that I had to edit CMakeLists.txt to make it work, I thought gnuradio would do it automatically .
    – Moe
    Mar 6, 2015 at 11:01
0

Update to answer by @manos:
As of GNU Radio 3.8+ the CMakeList.txt files have slightly changed.

The line one needs to change in the toplevel CMakeList.txt is:

find_package(Gnuradio "3.8" REQUIRED COMPONENTS blocks analog filter fft)

And in lib/CMakeList.txt:

target_link_libraries(gnuradio-tempest gnuradio::gnuradio-runtime gnuradio::gnuradio-blocks gnuradio::gnuradio-fft gnuradio::gnuradio-filter Volk::volk)

Source: https://wiki.gnuradio.org/index.php/GNU_Radio_3.8_OOT_Module_Porting_Guide

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.