VRPN Client with Qt Creator

Making & changing box plugins and external apps
Post Reply
Dox
Posts: 3
Joined: Sat Jan 20, 2018 10:15 am

VRPN Client with Qt Creator

Post by Dox »

Hi!

I am trying to build a VRPN client using Qt Creator as an IDE. I need Qt Creator because I am using it to the User interface and I wanted to add to my project a vrpn client.

So I followed the openVibe tutorial but I got some linking error:

Code: Select all

C:\Document\ConnectVRPN\main.cpp:33: erreur : undefined reference to `vrpn_Button_Remote::vrpn_Button_Remote(char const*, vrpn_Connection*)'
C:\Documents\ConnectVRPN\main.cpp:40: erreur : undefined reference to `vrpn_Analog_Remote::vrpn_Analog_Remote(char const*, vrpn_Connection*)'
collect2.exe:-1: erreur : error: ld returned 1 exit status
my .pro file is as followed:

Code: Select all

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/vrpn/lib/ -lvrpn
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/vrpn/lib/ -lvrpnd

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/vrpn/lib/ -lquat
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/vrpn/lib/ -lquatd

INCLUDEPATH += $$PWD/vrpn/include
DEPENDPATH += $$PWD/vrpn/include
here is my code:

Code: Select all

#include <iostream>

#include "vrpn/include/vrpn_Button.h"
#include "vrpn/include/vrpn_Analog.h"

void VRPN_CALLBACK vrpn_button_callback(void* user_data, vrpn_BUTTONCB button)
{
    std::cout << "Button ID : " << button.button << " / Button State : " << button.state << std::endl;

    if (button.button == 1)
    {
        *(bool*)user_data = false;
    }
}

void VRPN_CALLBACK vrpn_analog_callback(void* user_data, vrpn_ANALOGCB analog)
{
    for (int i = 0; i < analog.num_channel; i++)
    {
        std::cout << "Analog Channel : " << i << " / Analog Value : " << analog.channel[i] << std::endl;
    }
}

int main(int argc, char** argv)
{
    /* flag used to stop the program execution */
    bool running = true;

    /* VRPN Button object */
    vrpn_Button_Remote* VRPNButton;

    /* Binding of the VRPN Button to a callback */
    VRPNButton = new vrpn_Button_Remote( "openvibe_vrpn_button@localhost" );
    VRPNButton->register_change_handler( &running, vrpn_button_callback );

    /* VRPN Analog object */
    vrpn_Analog_Remote* VRPNAnalog;

    /* Binding of the VRPN Analog to a callback */
    VRPNAnalog = new vrpn_Analog_Remote( "openvibe_vrpn_analog@localhost" );
    VRPNAnalog->register_change_handler( NULL, vrpn_analog_callback );

    /* The main loop of the program, each VRPN object must be called in order to process data */
    while (running)
    {
        VRPNButton->mainloop();
    }

    return 0;
}
I also put the dependancies folder next to my .pro file (the path is good because include directive works).
I haven't the vrpn.a may be it's why it doesn't link well but I don't know how to find this file.

If you have succeed to build a vrpn client with Qt or you have any idea, please tell me.

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: VRPN Client with Qt Creator

Post by jtlindgren »

That is a bit odd. It shouldn't need more than correct include/lib paths and linking the libs. Two ideas,

1) did you pick the same version of vrpn that openvibe uses? This can be found by either running the dependency installer from the OV source package or by a direct download (links may change over time),

http://openvibe.inria.fr/dependencies/w ... 31-dev.zip
http://openvibe.inria.fr/dependencies/w ... untime.zip

2) are you sure its even trying to link the vrpn lib when compiling? I'm not familar with the qt syntax. Maybe you can have some way to know this, like increasing verbosity.


Best,
Jussi

Dox
Posts: 3
Joined: Sat Jan 20, 2018 10:15 am

Re: VRPN Client with Qt Creator

Post by Dox »

Hi,

(sorry for this late answer)

I have the same version of vrpn than openvibe. I get lib and include after running the dependency installer from the OV source package (and I also tried with direct download).

I am pretty sure that it's a linking trouble, because Qt see well the include files, but compilation failed when I try to declare an instance of a 'vrpn_Button_Remote::vrpn_Button_Remote' for example.

Anyone can try to link vrpn client with Qt creator?

tgaugry
Posts: 68
Joined: Thu Feb 09, 2017 10:17 am

Re: VRPN Client with Qt Creator

Post by tgaugry »

Hi,

Syntax seems to have changed for qmake.
If I believe http://doc.qt.io/qt-5/qmake-variable-reference.html, section "LIB", it seems that you should use this syntax

Code: Select all

win32:LIBS += c:/mylibs/math.lib


Can you try this out ?
If that does not solve it, can you tell us your Qt version ? (since you are using qmake)
Another pointer would be checking path are corrects using message command in qmake.

Hope that helps,

Dox
Posts: 3
Joined: Sat Jan 20, 2018 10:15 am

Re: VRPN Client with Qt Creator

Post by Dox »

Hi,

I tried it, but it doesn't change...
fail_compil.png
fail_compil.png (49.12 KiB) Viewed 12278 times
my Qt version:
qt_version.png
qt_version.png (15 KiB) Viewed 12278 times

Post Reply