Results 1 to 4 of 4

Thread: including external library or package to Qt

  1. #1
    Join Date
    Aug 2016
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default including external library or package to Qt

    I downloaded the following package : https://github.com/labapart/gattlib for discovery of BLE device, I could discover the devices using the commands specified on the link, however, now I want to use this code to develop my own application. I tried implementing this on Qt. I copied the BLE scan code in a .c file and below is my .pro file:
    TEMPLATE = app
    CONFIG += console c++11
    CONFIG -= app_bundle
    CONFIG -= qt
    QT += BluezQt
    SOURCES += \
    ble_scan.c
    packagesExist(glib-2.0) {
    CONFIG += link_pkgconfig
    PKGCONFIG += glib-2.0
    }

    LIBS += -pthread
    LIBS += -lbluetooth
    LIBS += -L/gattlib_0.2_x86_64/lib/pkgconfig
    HEADERS += \
    gattlib.h

    However, I keep on getting following errors:
    undefined reference to ''gattlib_connect'
    and other functions which are defined in gattlib.

    I think this has something to do with the package, could anyone please guide me on how to include this in Qt project. (I tried using cmake instead of qmake but it doesn't give any .pro file to add glib and bluetooth library, hence couldn't use it)

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: including external library or package to Qt

    undefined reference to ''gattlib_connect'
    This sounds like a compile-time error, not a link error. You have probably not added the proper #include to your source files for the headers for your library. It isn't enough just to add the header name to the .pro file.

    You will probably end up with link errors as well, because your LIBS doesn't contain the name of the library to link to; you have only specified the directory it lives in.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Aug 2016
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: including external library or package to Qt

    In the code #include statement for gattlib.h is present, I simply copied the following code: https://github.com/labapart/gattlib/...can/ble_scan.c
    Initially, I was getting compile time error for hci_le_set_scan_parameter and other functions which are a part of lbluetooth library, however, after including the same, i stopped getting error for the same. But I am not sure about how should I include the library in this case.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: including external library or package to Qt

    But I am not sure about how should I include the library in this case.
    The same way you include the other libraries:

    LIBS += -lgattlib (or whatever it is called).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Including library
    By Stank in forum Newbie
    Replies: 4
    Last Post: 12th July 2016, 14:51
  2. Including external header (gst.h)
    By Plox in forum Newbie
    Replies: 15
    Last Post: 25th December 2014, 22:33
  3. Replies: 2
    Last Post: 10th December 2013, 20:58
  4. Including a static library
    By jepessen in forum Newbie
    Replies: 3
    Last Post: 6th May 2011, 10:35
  5. Replies: 1
    Last Post: 6th November 2009, 22:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.