Important: Please read the Qt Code of Conduct -

LNK1104 after adding custom libaries

  • Hi everyone

    I'm pretty new to the whole Qt thing, but everything seems to be okay for me, besides this one. In my project, I need to use two third party libraries: RapidJSON and TinyXML2.

    I downloaded their code on GitHub, and compiled them using MingW (using g++ -o tinyxml2.o tinyxml2.h and then ar rcs libtinyxml2.a tinyxml2.o). After, I just added the library to my project, using Qt Creator, and tried to compile.
    But I can't. I get a LNK1104 error from the compiler: "can't open file 'tinyxml2d.lib'". After restarting, I also have this now :

    :-1: erreur : dependent 'D:\Users\thoma\Documents\TEST\C:\Libs\tinyxml2d.lib' does not exist.

    I mean, it's kind of normal it can find it since I only have .a and not .lib files. What am I missing ?

    I'm using Windows 10 (x64).


    By the way, here is my .pro file.

    EDIT : I tried to remove the various $$PWD/ from the .pro file, and I'm getting the first error message again.

  • Qt Champions 2017

    Hello Thomas,
    Welcome to the Qt forum!

    @TKowalski said in LNK1104 after adding custom libaries:

    I need to use two third party libraries: RapidJSON and TinyXML2.

    Qt provides support for both JSON and XML from the QtCore module.

    win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/C:/Libs/libtinyxml2.a
    else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/C:/Libs/libtinyxml2d.a
    else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/C:/Libs/tinyxml2.lib
    else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/C:/Libs/tinyxml2d.lib

    This assumes you're linking static libraries. Furthermore mingw (win32-g++) doesn't generate lib files, but archives - .a, because it's a port of Linux's g++ ... and based on this pro file I'd say you're compiling your project with MSVC (the error code/formatting is also a giveaway). You can't mix compilers! Either compile everything with MSVC or with mingw.

    Kind regards.

  • I guess I'll just use the Qt's implementations then. Thanks for the explanation though.

Log in to reply