Results 1 to 2 of 2

Thread: Linker can't resolve Qt symbols when building outside of creator

  1. #1
    Join Date
    Nov 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Linker can't resolve Qt symbols when building outside of creator

    Hi All,

    I have a Qt based shared library (of our own creation) that I can't build outside of creator in (Windows/MinGW-32 5.3). It works fine (compiles and links) in QtCreator. However, when I attempt to build from the command line using the same qmake project files (qmake/mingw32-make) however when linking the dll, the linker spits out an undefined reference for every single Qt symbol used in my library like so:

    Qt Code:
    1. g++ -Wl,-s -shared -Wl,-subsystem,windows -mthreads -Wl,--out-implib,release\libOslQtCommon.a -o release\OslQtCommon.dll object_script.OslQtCommon.Release -LD:\workspace-qt\Gordon_v1_0_1_b01\OslCommon\release -lOslCommon -LD:\workspace-qt\Gordon_v1_0_1_b01\IcIface\release -lIcIface -lws2_32 -liphlpapi -LC:\Qt5.7\5.7\mingw53_32\lib C:\Qt5.7\5.7\mingw53_32\lib\libQt5Widgets.a C:\Qt5.7\5.7\mingw53_32\lib\libQt5Gui.a C:\Qt5.7\5.7\mingw53_32\lib\libQt5Ftp.a -LC:\utils\postgresql\pgsql\lib -LC:\utils\my_sql\my_sql\lib C:\Qt5.7\5.7\mingw53_32\lib\libQt5Network.a C:\Qt5.7\5.7\mingw53_32\lib\libQt5SerialPort.a C:\Qt5.7\5.7\mingw53_32\lib\libQt5Core.a
    2. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0x950): undefined reference to `__imp__ZN7QObjectC2EPS_'
    3. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0x96a): undefined reference to `__imp__ZN7QString13toUtf8_helperERKS_'
    4. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xa21): undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
    5. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xa37): undefined reference to `__imp__ZN7QObjectD2Ev'
    6. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xb94): undefined reference to `__imp__ZN7QObjectD2Ev'
    7. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xbad): undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
    8. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xbcd): undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
    9. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xc55): undefined reference to `__imp__ZN7QString15fromUtf8_helperEPKci'
    10. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xc8d): undefined reference to `__imp__ZN7QString6appendERKS_'
    11. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xd2b): undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
    12. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xd4d): undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
    13. ./obj\oslwavlogger.o:oslwavlogger.cpp:(.text+0xd6d): undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
    14. [... ad infinitum]
    To copy to clipboard, switch view to plain text mode 

    I have compared the linker command used by Creator and it is identical to the one running at the command line except the paths since I'm building to a different location (I'm using a python script to generate the qmake/make cmds with the same options I have in creator). Since everything compiles OK and the linker has no problem finding the library files (all of Qt's .a/dll files) I'm thinking somehow the symbols are not being exported or imported. But as I said, here's no problem building in Creator so I guess this probably means Creator has something in its environment that is missing in my python environment but I can't figure it out. What would cause these (and all Qt symbols) to not get exported (or imported)?

    Any ideas?

  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: Linker can't resolve Qt symbols when building outside of creator

    Shouldn't all of these kind of things: "C:\Qt5.7\5.7\mingw53_32\lib\libQt5Widgets.a" be listed as "-lQt5Widgets" instead? You're already using the -L option to tell it where the libraries are. I don't think that simply listing the paths to the libraries works - you need to tell the linker that they are libraries by using the -l option on each one, AFAIK.

    Also, unlike the Microsoft Visual Studio linker, it is my experience that libraries must be listed in the order of dependency - if one library (A) depends on symbols from another (B), A must be listed before B on the link line.


    "Some people like cupcakes better. I for one care less for them!"
    <=== 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. Replies: 2
    Last Post: 19th December 2014, 10:47
  2. Cannot resolve the symbols from a custom dll
    By magpielover in forum Installation and Deployment
    Replies: 4
    Last Post: 22nd August 2011, 21:55
  3. Replies: 5
    Last Post: 14th October 2010, 19:43
  4. Qt 4.6 with VS 2008 Express: Linker error when building libraries
    By scrontch in forum Installation and Deployment
    Replies: 9
    Last Post: 10th January 2010, 16:25
  5. Linker error while building with a makefile
    By kamleshwark in forum Newbie
    Replies: 1
    Last Post: 18th July 2009, 00:06

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.