Я пытаюсь скомпилировать следующий код C ++ для генерации потокового графа gnuradio, но я сталкиваюсь со странной ошибкой компоновщика, которая имеет что-то с библиотекой uhd.
#include <gnuradio/top_block.h>
#include <gnuradio/filter/firdes.h>
#include <gnuradio/filter/freq_xlating_fir_filter_ccf.h>
#include <gnuradio/analog/quadrature_demod_cf.h>
#include <gnuradio/blocks/vector_sink_b.h>
#include <gnuradio/uhd/usrp_source.h>
#include <gnuradio/digital/clock_recovery_mm_cc.h>
#include <gnuradio/digital/binary_slicer_fb.h>
#include <gnuradio/analog/pwr_squelch_cc.h>
#include <gnuradio/blocks/unpacked_to_packed_bb.h>
#include <gnuradio/analog/pwr_squelch_cc.h>
using namespace std;
Linker error with the UHD library.int main(){
double transition_width = 300e3;
double sample_rate = 4e6;
double data_rate = 1e6;
double cutoff_freq = 2e6;
double ble_channel_spacing = 2e6;
int ble_channel = ble_channel = 38;
double ble_base_freq = 2402e6;
double squelch_threshold = -110;
double sensivity = 1.0;
double rf_gain = rf_gain = 74;
std::vector<float> taps = gr::filter::firdes::low_pass(1.0, sample_rate, cutoff_freq, transition_width, gr::filter::firdes::WIN_HAMMING, 6.76);
int gfsk_sps = (int)(sample_rate / data_rate);
float gfsk_omega_limit = 0.035;
float gfsk_mu = 0.5;
float gfsk_gain_mu = 0.8;
float freq_offset = 0.0;
double freq = ble_base_freq+(ble_channel_spacing * ble_channel);
float freq_error = 0.0;
///more parameters
float omega = gfsk_sps*(1.0+freq_error);
float gain_omega = .25 * gfsk_gain_mu * gfsk_gain_mu;gr::top_block_sptr tb = gr::make_top_block("dial_tone");
//setting up the USRP block
string device_addr = "192.168.10.1";
gr::uhd::usrp_source::sptr source = gr::uhd::usrp_source::make(device_addr, uhd::stream_args_t("fc32"));;
source->set_samp_rate(sample_rate);
source->set_center_freq(freq);
source->set_gain(rf_gain);
source->set_antenna("RX2",0);//setting up the filter
gr::filter::freq_xlating_fir_filter_ccf::sptr filter_ccc = gr::filter::freq_xlating_fir_filter_ccf::make(1,taps,0.0,sample_rate);
//demodulator setup
gr::analog::quadrature_demod_cf::sptr qi_demod = gr::analog::quadrature_demod_cf::make(1.0/sensivity);
//the clock recovery module
gr::digital::clock_recovery_mm_cc::sptr clock_rec = gr::digital::clock_recovery_mm_cc::make(omega,gain_omega,gfsk_mu,gfsk_gain_mu, gfsk_omega_limit);//setting the slicer
gr::digital::binary_slicer_fb::sptr slicer = gr::digital::binary_slicer_fb::make();
//unpacking
gr::blocks::unpacked_to_packed_bb::sptr unpack = gr::blocks::unpacked_to_packed_bb::make(1,gr::GR_LSB_FIRST);//power squelch
gr::analog::pwr_squelch_cc::sptr squelch = gr::analog::pwr_squelch_cc::make(squelch_threshold);//vector sink
gr::blocks::vector_sink_b::sptr vect_sink = gr::blocks::vector_sink_b::make();
///make the connections
tb->connect(source,0,squelch,0);
tb->connect(squelch,0,filter_ccc,0);
tb->connect(filter_ccc,0,qi_demod,0);
tb->connect(qi_demod,0,clock_rec,0);
tb->connect(clock_rec,0,slicer,0);
tb->connect(slicer,0,unpack,0);
tb->connect(unpack,0,vect_sink,0);
tb->start();
cout<<"gnuradio thread is running"<<endl;
tb->stop();
tb->wait();
return 0;
}
Я получаю следующую ошибку, которую мне трудно разрешить.
`Undefined symbols for architecture x86_64:
"uhd::device_addr_t::device_addr_t(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in gr_ble.cpp.o
uhd::stream_args_t::stream_args_t(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in gr_ble.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [gr_ble] Error 1
make[1]: *** [CMakeFiles/gr_ble.dir/all] Error 2
make: *** [all] Error 2
Ошибка исчезает, когда я удаляю источник usrp.
Ниже приведен мой файл make.
cmake_minimum_required(VERSION 2.6)
project(gr_ble CXX)
find_package(Boost "1.35" COMPONENTS system)
set(GR_REQUIRED_COMPONENTS RUNTIME ANALOG AUDIO BLOCKS FILTER DIGITAL UHD)
find_package(Gnuradio "3.7.2" REQUIRED)
include_directories(${GNURADIO_ALL_INCLUDE_DIRS})add_executable(gr_ble gr_ble.cpp)
target_link_libraries(gr_ble ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES})
Спасибо
Я вижу две проблемы здесь:
make()
, Посмотреть здесь: https://www.gnuradio.org/doc/doxygen-3.7.2/group__uhd__blk.htmluhd::device_addr_t
это карта. Если ваш USRP имеет IP 192.168.10.1, правильный способ идентифицировать это устройство addr=192.168.10.1
, Посмотреть здесь: https://files.ettus.com/manual/page_identification.htmlВероятно, вам также потребуется установить спецификацию подустройства (я не вижу этого в вашем коде). Посмотреть здесь: https://files.ettus.com/manual/page_configuration.html
Других решений пока нет …