Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Creating and adding a static library



  • Hi,
    I am using qt on windows now. I need to add the serial port library (http://code.google.com/p/qextserialport/source/checkout). First I build the library using the CONFIG += staticlib option and get a library with an extension with .a .Now I try to add the library to some example programs given in the event directory. I also add CONFIG += staticlib in the .pro file, but I always get errors like
    @qextserialport\examples\event-build-desktop/../event/PortListener.cpp:11: undefined reference to `_imp___ZN14QextSerialPort9setParityE10ParityType'@

    I think there is some linking issues, because it will work when linking with dll files, how to solve?



  • Please post your .pro file for the project that is not linking properly and could you let us know where the statically compiled library is located please?



  • Hi,
    Here is the complete project code (http://www.4shared.com/file/FFtrqBMR/qextserialport.html ), in which I tried the project in the examples/event folder, i.e

    @
    PROJECT = event
    TEMPLATE = app
    DEPENDPATH += .
    INCLUDEPATH += ../../src
    QMAKE_LIBDIR += ../../src-build-desktop/build
    CONFIG += staticlib

    OBJECTS_DIR = tmp
    MOC_DIR = tmp
    UI_DIR = tmp

    SOURCES += main.cpp PortListener.cpp
    HEADERS += PortListener.h

    CONFIG(debug, debug|release):LIBS += -lqextserialportd
    else:LIBS += -lqextserialport
    @
    I am using Qt libraries version 4.7.0, Qt Creator IDE version 2.0.1 in Windows
    Thanking You,
    Ras


Log in to reply