Forum: GNU Radio QT GUI FFTSINK in C++ Flowgraph

Posted by Daniel Labarowski (Guest)
on 2012-12-15 08:08
(Received via mailing list)
Hello,
I am attempting to use qt gui widgets in a C++ flowgraph. I managed to
get all of the build dependencies figured out, which was no easy task in
itself and required a lot of direct includes. Anyway, the error that I
am getting now deals directly with the make function. The line that is
giving me trouble is as follows

> qtgui_sink_c_sptr qtsink = qtgui_make_sink_c (fftsize,
> gr_firdes::WIN_HAMMING, 0, 1.0, "Spectrum Display", true, true, true,
> true, QWidget *parent=NULL);

Information on this function is available here.
<http://gnuradio.org/redmine/projects/gnuradio/wiki... The
error that I am getting is that parent is undefined. I really don't know
what to put for this. Note that I have also tried putting just NULL or
just 0 and it throws an undefined reference error (for the function
call). I was wondering if someone could give me some pointers on what to
use for parent? While I would eventually like to have both an fft and a
time domain view in a single window, I am currently just trying to get
the fft to show in its own window. Thanks ahead of time!

-Dan
Posted by Daniel Labarowski (Guest)
on 2012-12-16 23:24
(Received via mailing list)
I've been toying around with this a bit more. I added "#include
<QWidget>" to the top of my program. I also added "QWidget* parent = new
QWidget;" before my call to qtgui_make_sink_c and replaced "QWidget
*parent=NULL" white "parent". I am now getting the following error

> top_block.cc:(.text+0x8cd): undefined reference to
> `QWidget::QWidget(QWidget*, QFlags<Qt::WindowType>)'
> top_block.cc:(.text+0x94f): undefined reference to
> `qtgui_make_sink_c(int, int, double, double, std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&, bool, bool,
> bool, bool, QWidget*)'

I've double checked what little documentation I can find on
qtgui_make_sink_c and I think that I am passing appropriate parameters.
Any thoughts on what might be wrong?

-Dan
Posted by Tom Rondeau (Guest)
on 2012-12-17 16:41
(Received via mailing list)
On Sun, Dec 16, 2012 at 5:23 PM, Daniel Labarowski
<labarowski.1@gmail.com>wrote:

>
>
> I've double checked what little documentation I can find on
> qtgui_make_sink_c and I think that I am passing appropriate parameters. Any
> thoughts on what might be wrong?
>
> -Dan
>

This suggests that you are not linking against libgnuradio-qtgui.so. 
Make
sure you are (-lgnuradio-qtgui should be used when linking).

You probably also want to use NULL for the parent. As it is now, you're
using an empty QWidget, and I'm not sure what will happen with that, but 
it
probably won't work as expected.

From your first email, it looks like you are passing "QWiget* 
parent=NULL"
as the last parameter. Just say "NULL" here, instead.

I've never tried to use QTGUI in C++ apps, so I'm curious to know if you
can get it to work.

Tom
Posted by Marcus D. Leech (Guest)
on 2012-12-17 16:48
(Received via mailing list)
> I've never tried to use QTGUI in C++ apps, so I'm curious to know if
> you can get it to work.
>
> Tom
>
I believe that gqrx is an instance of an app that uses both QtGUI, and
Gnu Radio, and is largely written in C++, and is open source.  Valuable
   hints might be gleaned by looking at that source code.


--
Marcus Leech
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org
Posted by Alexandru Csete (Guest)
on 2012-12-17 20:57
(Received via mailing list)
On Mon, Dec 17, 2012 at 4:47 PM, Marcus D. Leech <mleech@ripnet.com> 
wrote:
>> I've never tried to use QTGUI in C++ apps, so I'm curious to know if you
>> can get it to work.
>>
>> Tom
>>
> I believe that gqrx is an instance of an app that uses both QtGUI, and Gnu
> Radio, and is largely written in C++, and is open source.  Valuable
>   hints might be gleaned by looking at that source code.
>

Hi Marcus,

The initial gqrx was a python application that used gr-qtgui. Since
then I have started from scratch and created a new application using
C++ and Qt for gui but not the gr-qtgui component.

Alex
Posted by Daniel Labarowski (Guest)
on 2012-12-20 02:00
(Received via mailing list)
Thanks for the replies guys. Tom, I have modified this flowgraph
(extensively) from one of the examples and have been using its
CMakeLists.txt file (modifying it along the way of course). The commands
that I use to build it are

> mkdir build
> cd build
> cmake ../
> make

I believe that -l gnuradio-qtgui would be for g++. Since I am not using
g++ directly I tried adding the following to my CMakeLists.txt file.


> # libgnuradio-qtgui.so
> #find_package(gnuradio-qtgui)
> include_directories(/usr/local/lib)

When the find_package command did not work, I commented it out and
included the directory absolutely. I have had to do this a lot lately.
Some of the library variables seem to have not gotten set by the build
script (granted, this build is from the summer). Unfortunately I am
still getting the

> undefined reference to `qtgui_make_sink_c(int, int, double, double,
> std::basic_string<char, std::char_traits<char>, std::allocator<char> >
> const&, bool, bool, bool, bool, QWidget*)'

error. My syntax is

> qtgui_sink_c_sptr qtsink = qtgui_make_sink_c (fftsize,
> gr_firdes::WIN_HAMMING, 0, 1.0, "Spectrum Display", true, true, true,
> true, NULL);

I am including the following relevant components

> #include <qtgui_sink_c.h>
> #include <QApplication>
> #include <QWidget>

Can anyone spot my mistake?

-Dan
Posted by Tom Rondeau (Guest)
on 2012-12-20 04:07
(Received via mailing list)
On Wed, Dec 19, 2012 at 2:56 AM, Daniel Labarowski
<labarowski.1@gmail.com>wrote:

>
> included the directory absolutely. I have had to do this a lot lately. Some
>
>>
>
> Can anyone spot my mistake?
>
> -Dan
>


Hi Dan,

The problem is not in the includes, its in the linking library.  Try 
using:

target_link_libraries(<target to build> <list of libraries like
gnuradio-qtgui>)

Tom
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.