Hi Zhihong Luo,
you're not linking your program against any GNU Radio component,
which is why the linker step in your compiler call complains about
all the symbols from these libraries missing.
Normally, it's the job of a build system to set up your compiler
call correctly, but in this case, somethin like
g++ tags.cpp -o tags $(pkg-config --libs --cflags gnuradio-runtime
gnuradio-uhd)
should work.
I'd still recommend not doing that, but using gr_modtool to create a
new out-of-tree module
gr_modtool newmod
and add your file in the <modulename>/apps/ folder, adding the
filename to <modulename>/apps/CMakeLists.txt under "sources".
Add "uhd" to the list of necessary GNU Radio components in
<modulename>/CMakeLists.txt
Then, it's the normal CMake build procedure:
cd <modulename>
mkdir build
cd build
cmake ..
make
make install
On 03.02.2016 09:39, Zhihong Luo wrote:
Hi Marcus,
Sorry, I was typing and accidentally sent it out the previous
one... The code is
#include<gnuradio/top_block.h>
#include<gnuradio/uhd/usrp_source.h>
#include<uhd/utils/safe_main.hpp>
#include <boost/make_shared.hpp>
#include <boost/thread/thread.hpp>
#include
<boost/program_options.hpp>
#include <csignal>
#include <iostream>
namespace
po =
boost::program_options;
int
UHD_SAFE_MAIN(int argc, char *argv[]){
std::string device_addr =" "; |
|
gr::top_block_sptr
tb = gr::make_top_block("tags_demo"); |
|
gr::uhd::usrp_source::sptr usrp_source =
gr::uhd::usrp_source::make(device_addr,
uhd::stream_args_t("fc32"));
|
}
Then I ran the command:
g++ tags.cpp -o tags -l boost_system
which ends up having errors:
undefined reference to gr::make_top_block,
uhd::device_addr_t, gr::uhd::usrp_source and etc.
Thanks,
Zhihong Luo