using libfranka with Qt yields 'undefined reference' error
sdfzz opened this issue · 1 comments
sdfzz commented
Hi all,
I'm trying to use libfranka with Qt.
I've installed libfranka as described in "https://frankaemika.github.io/docs/installation_linux.html" following "building libfranka", and I can run examples without any problems.
However, when I try to write my own code in Qt, I get the following error:
/root/Projects/TEST/frankaTest/mainwindow.cpp:-1: error: undefined reference to `franka::Robot::Robot(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, franka::RealtimeConfig, unsigned long)'
I've added libfranka/include folder to my ".pro" file and I can import all headers alright.
My header:
#include <franka/duration.h>
#include <franka/exception.h>
#include <franka/model.h>
#include <franka/robot.h>
My source:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
try{
franka::Robot robot("127.0.0.1");
} catch(franka::Exception const& e){
qDebug() << e.what();
}
}
Any help would be greatly appreciated
Sincerely,
Steve
sdfzz commented
I'm happy to post the solution to my own question.
To use libfranka on Qt,
- Install libfranka library, follwoing "building libfranka" of "https://frankaemika.github.io/docs/installation_linux.html" . I did not build/install deb package.
- Create a new qt project, open .pro file, right click, select 'add library'. Choose 'external library' and select libfranka.so file in libfranka/build folder
- Add the following to .pro:
INCLUDEPATH += /path_to_libfranka/include/
Now I can build the code above. Hope this helps other qt newbies like me.
Sincerely,
Steve