I've been attempting to port an old utility to GNU Radio 3.9/3.10. Linking the program results in many undefined symbol errors, for symbols that are in the shared libraries being linked. I can't figure out what I'm missing, and nothing I've tried has helped.
This issue sounds familiar to what I'm seeing (and I did see undefined symbols related to log4cpp, which went away when I added -llog4cpp
to the linker flags). I assume what I'm missing is something by extending GNU Radio classes with the classes here, but I can't tell what.
The error message in all its glory:
g++ -DVERSION="\"gr-scan 2013102901\"" -I/usr/local/include -Wall -g -std=c++11 -Wno-unused-function -c -o main.o main.cpp
In file included from main.cpp:22:
arguments.hpp: In member function ‘error_t Arguments::parse_opt(int, char*, argp_state*)’:
arguments.hpp:168:6: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
168 | if (outcsv_writeheader)
| ^~
arguments.hpp:170:7: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
170 | fflush(outcsv);
| ^~~~~~
g++ -DVERSION="\"gr-scan 2013102901\"" -I/usr/local/include -Wall -g -std=c++11 -Wno-unused-function -c -o scanner_sink.o scanner_sink.cpp
g++ -DVERSION="\"gr-scan 2013102901\"" -I/usr/local/include -Wall -g -std=c++11 -Wno-unused-function -c -o topblock.o topblock.cpp
g++ -DVERSION="\"gr-scan 2013102901\"" -I/usr/local/include -Wall -g -std=c++11 -Wno-unused-function -lstdc++ -llog4cpp -lboost_system -lgnuradio-blocks -lgnuradio-pmt -lgnuradio-fft -lgnuradio-osmosdr -lgnuradio-runtime -lpython3.8 -L/usr/local/lib/x86_64-linux-gnu -o gr-scan main.o scanner_sink.o topblock.o
/usr/bin/ld: main.o: in function `main':
/home/atuonuc/src/gr-scan/main.cpp:42: undefined reference to `gr::top_block::run(int)'
/usr/bin/ld: scanner_sink.o: in function `scanner_sink::scanner_sink(std::shared_ptr<osmosdr::source>, unsigned int, double, double, double, double, double, double, unsigned int, double, double, double, _IO_FILE*)':
/home/atuonuc/src/gr-scan/scanner_sink.cpp:40: undefined reference to `gr::buffer_double_mapped::type'
/usr/bin/ld: /home/atuonuc/src/gr-scan/scanner_sink.cpp:40: undefined reference to `gr::io_signature::make(int, int, int, gr::buffer_type_base const&)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/scanner_sink.cpp:39: undefined reference to `gr::buffer_double_mapped::type'
/usr/bin/ld: /home/atuonuc/src/gr-scan/scanner_sink.cpp:39: undefined reference to `gr::io_signature::make(int, int, int, gr::buffer_type_base const&)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/scanner_sink.cpp:57: undefined reference to `gr::block::block(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<gr::io_signature>, std::shared_ptr<gr::io_signature>)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/scanner_sink.cpp:57: undefined reference to `gr::block::~block()'
/usr/bin/ld: scanner_sink.o: in function `scanner_sink::~scanner_sink()':
/home/atuonuc/src/gr-scan/scanner_sink.cpp:62: undefined reference to `gr::block::~block()'
/usr/bin/ld: scanner_sink.o: in function `scanner_sink::general_work(int, std::vector<int, std::allocator<int> >&, std::vector<void const*, std::allocator<void const*> >&, std::vector<void*, std::allocator<void*> >&)':
/home/atuonuc/src/gr-scan/scanner_sink.cpp:80: undefined reference to `gr::block::consume_each(int)'
/usr/bin/ld: scanner_sink.o: in function `pmt::comparator::operator()(std::shared_ptr<pmt::pmt_base> const&, std::shared_ptr<pmt::pmt_base> const&) const':
/usr/include/pmt/pmt.h:976: undefined reference to `pmt::eqv(std::shared_ptr<pmt::pmt_base> const&, std::shared_ptr<pmt::pmt_base> const&)'
/usr/bin/ld: scanner_sink.o: in function `gr::msg_queue_comparator::operator()(std::shared_ptr<pmt::pmt_base> const&, std::shared_ptr<pmt::pmt_base> const&) const':
/usr/include/gnuradio/basic_block.h:39: undefined reference to `pmt::eqv(std::shared_ptr<pmt::pmt_base> const&, std::shared_ptr<pmt::pmt_base> const&)'
/usr/bin/ld: /usr/include/gnuradio/basic_block.h:41: undefined reference to `pmt::eqv(std::shared_ptr<pmt::pmt_base> const&, std::shared_ptr<pmt::pmt_base> const&)'
/usr/bin/ld: scanner_sink.o: in function `gr::basic_block::has_msg_port(std::shared_ptr<pmt::pmt_base>)':
/usr/include/gnuradio/basic_block.h:311: undefined reference to `pmt::dict_has_key(std::shared_ptr<pmt::pmt_base> const&, std::shared_ptr<pmt::pmt_base> const&)'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0x20): undefined reference to `gr::msg_accepter::post(std::shared_ptr<pmt::pmt_base>, std::shared_ptr<pmt::pmt_base>)'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0x68): undefined reference to `gr::block::set_processor_affinity(std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0x70): undefined reference to `gr::block::unset_processor_affinity()'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0x80): undefined reference to `gr::block::set_log_level(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0x88): undefined reference to `gr::block::log_level[abi:cxx11]()'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0x90): undefined reference to `gr::block::forecast(int, std::vector<int, std::allocator<int> >&)'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0xa0): undefined reference to `gr::block::start()'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0xa8): undefined reference to `gr::block::stop()'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0xb0): undefined reference to `gr::block::fixed_rate_ninput_to_noutput(int)'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTV12scanner_sink[_ZTV12scanner_sink]+0xb8): undefined reference to `gr::block::fixed_rate_noutput_to_ninput(int)'
/usr/bin/ld: scanner_sink.o:(.data.rel.ro._ZTI12scanner_sink[_ZTI12scanner_sink]+0x10): undefined reference to `typeinfo for gr::block'
/usr/bin/ld: topblock.o: in function `TopBlock::TopBlock(double, double, double, double, double, double, double, unsigned int, double, double, double, _IO_FILE*)':
/home/atuonuc/src/gr-scan/topblock.cpp:46: undefined reference to `gr::top_block::top_block(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:46: undefined reference to `osmosdr::source::make(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:46: undefined reference to `gr::blocks::stream_to_vector::make(unsigned long, unsigned long)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:46: undefined reference to `gr::fft::fft_v<double, true>::make(int, std::vector<float, std::allocator<float> > const&, bool, int)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:46: undefined reference to `gr::blocks::complex_to_mag_squared::make(unsigned long)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:46: undefined reference to `gr::filter::single_pole_iir_filter_ff::make(double, unsigned int)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:46: undefined reference to `gr::blocks::nlog10_ff::make(float, unsigned long, float)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:57: undefined reference to `gr::hier_block2::connect(std::shared_ptr<gr::basic_block>, int, std::shared_ptr<gr::basic_block>, int)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:58: undefined reference to `gr::hier_block2::connect(std::shared_ptr<gr::basic_block>, int, std::shared_ptr<gr::basic_block>, int)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:59: undefined reference to `gr::hier_block2::connect(std::shared_ptr<gr::basic_block>, int, std::shared_ptr<gr::basic_block>, int)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:60: undefined reference to `gr::hier_block2::connect(std::shared_ptr<gr::basic_block>, int, std::shared_ptr<gr::basic_block>, int)'
/usr/bin/ld: /home/atuonuc/src/gr-scan/topblock.cpp:61: undefined reference to `gr::hier_block2::connect(std::shared_ptr<gr::basic_block>, int, std::shared_ptr<gr::basic_block>, int)'
/usr/bin/ld: topblock.o:/home/atuonuc/src/gr-scan/topblock.cpp:62: more undefined references to `gr::hier_block2::connect(std::shared_ptr<gr::basic_block>, int, std::shared_ptr<gr::basic_block>, int)' follow
/usr/bin/ld: topblock.o: in function `TopBlock::TopBlock(double, double, double, double, double, double, double, unsigned int, double, double, double, _IO_FILE*)':
/home/atuonuc/src/gr-scan/topblock.cpp:46: undefined reference to `gr::top_block::~top_block()'
/usr/bin/ld: topblock.o: in function `TopBlock::~TopBlock()':
/home/atuonuc/src/gr-scan/topblock.cpp:65: undefined reference to `gr::top_block::~top_block()'
/usr/bin/ld: topblock.o: in function `gr::hier_block2::message_port_is_hier_in(std::shared_ptr<pmt::pmt_base>)':
/usr/include/gnuradio/hier_block2.h:218: undefined reference to `pmt::list_has(std::shared_ptr<pmt::pmt_base>, std::shared_ptr<pmt::pmt_base> const&)'
/usr/bin/ld: topblock.o: in function `gr::hier_block2::message_port_is_hier_out(std::shared_ptr<pmt::pmt_base>)':
/usr/include/gnuradio/hier_block2.h:223: undefined reference to `pmt::list_has(std::shared_ptr<pmt::pmt_base>, std::shared_ptr<pmt::pmt_base> const&)'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x20): undefined reference to `gr::msg_accepter::post(std::shared_ptr<pmt::pmt_base>, std::shared_ptr<pmt::pmt_base>)'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x58): undefined reference to `gr::top_block::setup_rpc()'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x68): undefined reference to `gr::hier_block2::set_processor_affinity(std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x70): undefined reference to `gr::hier_block2::unset_processor_affinity()'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x78): undefined reference to `gr::hier_block2::processor_affinity()'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x80): undefined reference to `gr::hier_block2::set_log_level(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x88): undefined reference to `gr::hier_block2::log_level[abi:cxx11]()'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x90): undefined reference to `gr::top_block::lock()'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTV8TopBlock[_ZTV8TopBlock]+0x98): undefined reference to `gr::top_block::unlock()'
/usr/bin/ld: topblock.o:(.data.rel.ro._ZTI8TopBlock[_ZTI8TopBlock]+0x10): undefined reference to `typeinfo for gr::top_block'
collect2: error: ld returned 1 exit status
make: *** [Makefile:24: gr-scan] Error 1
I've made an issue on my fork of this program. I'm running this on Ubuntu 20.04, on an Intel NUC system. I've got the official GNU Radio 3.10.4 packages installed.
So, what basic C++ thing am I missing here?