Forum: GNU Radio Interfacing to USRP2 with C++

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D258a38939885cfade2b631818f693af?d=identicon&s=25 Jonathan Peck (Guest)
on 2009-02-03 22:32
(Received via mailing list)
Hi,
  I am currently trying to write a C++ program that interfaces to
USRP2. I was able to successfully complete the tutorial found at
http://www.gnuradio.org/trac/wiki/UsrpFAQ/CppInterface for interfacing
to the USRP1 despite the example code being a little outdated.  What
changes with interfacing with USRP2? Is there a similar tutorial for
the USRP2?

Thanks in advance!

Jon Peck
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-02-03 23:00
(Received via mailing list)
On Tue, Feb 03, 2009 at 04:29:12PM -0500, Jonathan Peck wrote:
> Hi,
>   I am currently trying to write a C++ program that interfaces to
> USRP2. I was able to successfully complete the tutorial found at
> http://www.gnuradio.org/trac/wiki/UsrpFAQ/CppInterface for interfacing
> to the USRP1 despite the example code being a little outdated.  What
> changes with interfacing with USRP2? Is there a similar tutorial for
> the USRP2?
>
> Thanks in advance!
> Jon Peck

There's no tutorial.

Have you looked at usrp2/host/include/usrp2/usrp2.h?

Eric
D258a38939885cfade2b631818f693af?d=identicon&s=25 Jonathan Peck (Guest)
on 2009-02-04 15:48
(Received via mailing list)
Eric,
  Yes, I have looked at that header file.  I wrote a small program to
try using the usrp2 class and tried to compile it without success.

Code usrp_demo.cc:
#include <usrp2/usrp2.h>

int main()
{
  const char *interface = "eth0";
  const char *mac_addr_str = "00:05:2c:85:30:a7";

  usrp2::usrp2::sptr u2 = usrp2::usrp2::make(interface, mac_addr_str);

  /* do stuff here */

  return 0;
}

g++ Output:
jpeck@LT14:~/usrp2-demo/usrp2-getdata$ g++ usrp2_demo.cc -o usrp2demo
-lusrp2
/usr/local/lib/libusrp2.so: undefined reference to
`gruel::sys_pri::usrp2_backend()'
/usr/local/lib/libusrp2.so: undefined reference to
`gruel::enable_realtime_scheduling(gruel::rt_sched_param)'
collect2: ld returned 1 exit status

Any idea on what I'm doing wrong?

-Jon
D0072e69d706bb3ca211d33a1b536e2c?d=identicon&s=25 Johnathan Corgan (Guest)
on 2009-02-04 16:21
(Received via mailing list)
On Wed, 2009-02-04 at 08:59 -0500, Jonathan Peck wrote:

> g++ Output:
> jpeck@LT14:~/usrp2-demo/usrp2-getdata$ g++ usrp2_demo.cc -o usrp2demo -lusrp2
> /usr/local/lib/libusrp2.so: undefined reference to
> `gruel::sys_pri::usrp2_backend()'
> /usr/local/lib/libusrp2.so: undefined reference to
> `gruel::enable_realtime_scheduling(gruel::rt_sched_param)'
> collect2: ld returned 1 exit status

You need to also link in the libgruel and omnithreads library.  An easy
way to do this is to use the pkg-config command.  To compile and link in
one step your single .cc file:

g++ -o usrp_demo `pkg-config --cflags --libs usrp2` usrp_demo.cc

The pkg-config utility will use our supplied configuration files and
create the proper compiler and linker flags for you.

Johnathan
This topic is locked and can not be replied to.