c++ - GNU Radio 使错误 : "reference to ‘uhd’ is ambiguous"

标签 c++ makefile gnuradio

我在 gnuradio companion (grc) 中创建了一个 bpsk 流程图,它工作正常。目前,我正在使用 gnuradio 类编写与同一程序等效的 C++。首先,我从一个文件中读取 I/Q 数据,然后我能够获得所有 bpsk 调制的 AX.25 帧。现在我试图用 UHD 文件源 block 替换文件源 block ,以便能够实时读取 I/Q 数据。 make 报告错误“对‘uhd’的引用不明确”。完整的 make 输出如下所示

 $ make
[ 50%] Building CXX object CMakeFiles/bpsk.dir/bpsk.cc.o
/home/mbkitine/Dropbox/Lulea/GRC/SSC/PSK/bpsk/RX_C++/bpsk.cc: In function ‘int main(int, char**)’:
/home/mbkitine/Dropbox/Lulea/GRC/SSC/PSK/bpsk/RX_C++/bpsk.cc:85:78: error: reference to ‘uhd’ is ambiguous
   gr::uhd::usrp_source::sptr uhd_source = gr::uhd::usrp_source::make(address,uhd::stream_args_t("fc32"));
                                                                              ^
In file included from /usr/local/include/uhd/types/metadata.hpp:22:0,
                 from /usr/local/include/uhd/stream.hpp:22,
                 from /usr/local/include/uhd/device.hpp:22,
                 from /usr/local/include/uhd/usrp/multi_usrp.hpp:37,
                 from /usr/local/include/gnuradio/uhd/usrp_block.h:28,
                 from /usr/local/include/gnuradio/uhd/usrp_source.h:26,
                 from /home/mbkitine/Dropbox/Lulea/GRC/SSC/PSK/bpsk/RX_C++/bpsk.cc:56:
/usr/local/include/uhd/types/time_spec.hpp:25:14: note: candidates are: namespace uhd { }
 namespace uhd{
              ^
In file included from /usr/local/include/gnuradio/uhd/usrp_source.h:26:0,
                 from /home/mbkitine/Dropbox/Lulea/GRC/SSC/PSK/bpsk/RX_C++/bpsk.cc:56:
/usr/local/include/gnuradio/uhd/usrp_block.h:31:17: note:                 namespace gr::uhd { }
   namespace uhd {
                 ^
CMakeFiles/bpsk.dir/build.make:62: recipe for target 'CMakeFiles/bpsk.dir/bpsk.cc.o' failed
make[2]: *** [CMakeFiles/bpsk.dir/bpsk.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/bpsk.dir/all' failed
make[1]: *** [CMakeFiles/bpsk.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

这是我的 bpsk.cc 代码

// Include header files for each block used in flowgraph
#include <gnuradio/top_block.h>
#include <gnuradio/analog/sig_source_f.h>
#include <gnuradio/analog/agc2_cc.h>
#include <gnuradio/digital/fll_band_edge_cc.h>
#include <gnuradio/digital/pfb_clock_sync_ccf.h>
#include <gnuradio/filter/firdes.h>
#include <gnuradio/digital/cma_equalizer_cc.h>
#include <gnuradio/digital/costas_loop_cc.h>
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
#include <gnuradio/digital/binary_slicer_fb.h>
#include <gnuradio/digital/diff_decoder_bb.h>
#include <gnuradio/digital/hdlc_deframer_bp.h>
#include <gnuradio/blocks/message_debug.h>
#include <gnuradio/audio/sink.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/uhd/usrp_source.h>
#include <ais/invert.h>
#include <gnuradio/blocks/complex_to_real.h>
#include <iostream>
#include <string>

using namespace gr;
int main(int argc, char **argv)
{
  //Extracting variables from the menu
  char* filename = argv[1];

  //UHD Default parameters
  double samp_rate = 1000000;
  double baud_rate = 250000;
  double fc        = 100e6;
  int sps          = int(samp_rate/baud_rate);

  //Receiver parameters
  int dec       = 10;
  float loop_bw = 2 * 3.14/100;

  // Construct a top block that will contain flowgraph blocks.  Alternatively,
  // one may create a derived class from top_block and hold instantiated blocks
  // as member data for later manipulation.
  top_block_sptr tb = make_top_block("bpsk");

  //UHD block
  std::string address = "192.168.10.2";
  gr::uhd::usrp_source::sptr uhd_source = gr::uhd::usrp_source::make(address,uhd::stream_args_t("fc32"));
  uhd_source->set_samp_rate(samp_rate);
  uhd_source->set_center_freq(fc);

  //Reading bpsk signal from file
  //blocks::file_source::sptr file = blocks::file_source::make(sizeof(gr_complex),filename,false);

  //Automatic gain controller
  analog::agc2_cc::sptr agc = analog::agc2_cc::make(1e-1, 1e-2, 1.0, 1.0);

  //FLL band edge filter
  digital::fll_band_edge_cc::sptr fll = digital::fll_band_edge_cc::make(sps, 0.5, 44, loop_bw);

  //PFB symbol time recovery
  const int nfilts = 32;
  std::vector<float> rrc_taps = filter::firdes::root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts);
  digital::pfb_clock_sync_ccf::sptr pfb = digital::pfb_clock_sync_ccf::make(sps,loop_bw,rrc_taps,nfilts,0,1.5,2);

  //CMA equalization
  digital::cma_equalizer_cc::sptr cma = digital::cma_equalizer_cc::make(15,1,0.01,2);

  //Costas loop
  digital::costas_loop_cc::sptr costas = digital::costas_loop_cc::make(loop_bw,2);

  //Taking the real part
  gr::blocks::complex_to_real::sptr comp_to_real = blocks::complex_to_real::make(1);

  //Binary slicer
  digital::binary_slicer_fb::sptr slicer  = digital::binary_slicer_fb::make();

  //Differential decoder
  digital::diff_decoder_bb::sptr differential_decoder = digital::diff_decoder_bb::make(2);

  //Inverting bit values
  //invert::sptr inverter = ais::invert::make();

  //HDLC Deframer
  digital::hdlc_deframer_bp::sptr deframer =  digital::hdlc_deframer_bp::make(32,500);

  //Output data
  gr::blocks::message_debug::sptr msg = gr::blocks::message_debug::make();

  std::cout << "Blocks declared successfully " << std::endl;
  //Connections
  tb->connect(uhd_source,0,agc,0);
  tb->connect(agc,0,fll,0);
  tb->connect(fll,0,pfb,0);
  tb->connect(pfb,0,cma,0);
  tb->connect(cma,0,costas,0);
  tb->connect(costas,0,comp_to_real,0);
  tb->connect(comp_to_real,0,slicer,0);
  tb->connect(slicer,0,differential_decoder,0);
  tb->connect(differential_decoder,0,deframer,0);
  //tb->connect(inverter,0,deframer,0);
  tb->msg_connect(deframer,"out",msg,"print_pdu");
  tb->run();
  std::cout << "The GNU Radio Thread is Running " << std::endl;

  // Exit normally.
  return 0;
}

最后是我的 CMakelists.txt 文件。我基本上修改了原始拨号音 C++ 示例中的这个文件,该示例可以在 {YOUR_GNURADIO_DIRECTORY}/gr-audio/examples/c++

中找到
cmake_minimum_required(VERSION 2.6)
project(bpsk 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(bpsk bpsk.cc)
target_link_libraries(bpsk ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES})

任何帮助将不胜感激。

问候

摩西。

最佳答案

错误说明那里出了什么问题:

因为你在做

 using namespace gr;

你的编译器不能知道你的意思是gr::uhd还是uhd

我只是建议删除 using namespace gr 指令。或者,当您真正指的是非 gr:: 命名空间时,使用 ::uhd

关于c++ - GNU Radio 使错误 : "reference to ‘uhd’ is ambiguous",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43735391/

相关文章:

c++ - 有没有办法避免模板友元声明的外部可见性?

c++ - AllocConsole 与 Visual Studio 2013

linux - 为旧内核设置 buildroot

gnuradio - 使用 GNURadio 进行 NRZ(解码)编码

gnuradio - 在为 GNU Radio 开发时,我应该使用 WX GUI 还是 Qt GUI 小部件?

c++ - 链接方法给了我意想不到的结果,并且正在以相反的顺序评估参数

c++ - linux C++ gmake "No rule to make target"

makefile - makefile 中的变量 $(MAKE) 是什么?

ubuntu-16.04 - GNU Radio Companion WX Instrumentation

android - 在 Android NDK 中捕获 C++ 信号并仍然打印故障转储