Important: Please read the Qt Code of Conduct -

Link my Qt static library in to non Qt linux application

  • Hello,

    I have build my Qt project as a static library and I have libabc.a

    I want to link this library with other non Qt application. (Example "test")

    I have used LIBPATH and set the path for my library.

    And used LIBS and passed -labc to for the linkage.

    But, when I build the application "test", While linking my Qt library, I get linker error:

    /home/kumararajas/Blah/lib/libuicorelib.a(moc_telephonedelegate.o): In function `TelephoneDelegate::connectCall(bool)':
    moc_telephonedelegate.cpp:(.text+0x60): undefined reference to `QMetaObject::activate(QObject*, QMetaObject const*, int, void**)'
    /home/kumararajas/Blah/lib/libuicorelib.a(moc_telephonedelegate.o): In function `TelephoneDelegate::qt_metacall(QMetaObject::Call, int, void**)':
    moc_telephonedelegate.cpp:(.text+0xb4): undefined reference to `QItemDelegate::qt_metacall(QMetaObject::Call, int, void**)'
    /home/kumararajas/Integrate_UI/G-CPU/lib/libuicorelib.a(moc_telephonedelegate.o): In function `TelephoneDelegate::qt_metacast(char const*)':
    moc_telephonedelegate.cpp:(.text+0x12c): undefined reference to `QItemDelegate::qt_metacast(char const*)'
    /home/kumararajas/Blah/lib/libuicorelib.a(moc_telephonedelegate.o): In function `TelephoneDelegate::~TelephoneDelegate()':
    moc_telephonedelegate.cpp:(.text._ZN17TelephoneDelegateD2Ev[_ZN17TelephoneDelegateD5Ev]+0x20): undefined reference to `QItemDelegate::~QItemDelegate()'

    Is there anything more that I need to do link my Qt static library?


  • Further to this post,

    I continued with different tries.


    I did try this:

     -lQtGuiE -lEGL -lIMGegl -lsrv_um -lQtNetworkE -lQtCoreE -lpthread 

    I linked the application "test" with my library and also with the above mentioned list.

    This solves the problem.
    Since the my Qt static library depends on other Qt libraries, i should link them as well..


  • But this time, I have a different error:

    /home/kumararajas/ti-sdk-am335x-evm- /home/kumararajas/Integrate_UI/G-CPU/lib/libuicorelib.a(uicontroller.o): undefined reference to symbol '__cxa_begin_catch@@CXXABI_1.3'
    /home/kumararajas/ti-sdk-am335x-evm- note: '__cxa_begin_catch@@CXXABI_1.3' is defined in DSO /home/kumararajas/ti-sdk-am335x-evm- so try adding it to the linker command line
    /home/kumararajas/ti-sdk-am335x-evm- could not read symbols: Invalid operation
    collect2: error: ld returned 1 exit status
    make[4]: *** [bin/FireApp] Error 1
    make[3]: *** [libraries] Error 2
    make[2]: *** [libraries] Error 2
    make[1]: *** [libraries] Error 2

    This looks like standard library compatibility issue.

    Any thoughts on this?