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

Can't link my app with static Qt



  • Hello, I'm trying to build my app statically, so my .pro file looks like this :

    CONFIG += c++17 object_parallel_to_source static
    QMAKE_LFLAGS += -static -static-libgcc -static-libstdc++
    TEMPLATE = app
    

    but when I hit Ctrl+B, the compiler returns this :

    23:13:31: Débute : "/usr/bin/make" -j4
    g++ -static -static-libgcc -static-libstdc++ -Wl,-O1 -o Ethyme media/jacques/Stockage/Developpement/CPP/phantomstyle-master/src/phantom/phantomcolor.o media/jacques/Stockage/Developpement/CPP/phantomstyle-master/src/phantom/phantomstyle.o aboutqt.o aboutphantomstyle.o cgu.o chat.o client/managers/messagemanager.o client/structures/channel.o client/structures/message.o constants.o editprofile.o main.o mainwindow.o register.o chat/channelButton.o chat/messagecomponent.o client/client.o client/managers/channelmanager.o client/managers/usermanager.o client/structures/clientuser.o client/structures/user.o client/websocket/websocketmanager.o home/jacques/Documents/Development/Ethyme/build/Release/moc_aboutphantomstyle.o home/jacques/Documents/Development/Ethyme/build/Release/moc_aboutqt.o home/jacques/Documents/Development/Ethyme/build/Release/moc_cgu.o home/jacques/Documents/Development/Ethyme/build/Release/moc_chat.o home/jacques/Documents/Development/Ethyme/build/Release/moc_messagemanager.o home/jacques/Documents/Development/Ethyme/build/Release/moc_channel.o home/jacques/Documents/Development/Ethyme/build/Release/moc_message.o home/jacques/Documents/Development/Ethyme/build/Release/moc_editprofile.o home/jacques/Documents/Development/Ethyme/build/Release/moc_mainwindow.o home/jacques/Documents/Development/Ethyme/build/Release/moc_register.o home/jacques/Documents/Development/Ethyme/build/Release/moc_channelButton.o home/jacques/Documents/Development/Ethyme/build/Release/moc_messagecomponent.o home/jacques/Documents/Development/Ethyme/build/Release/moc_client.o home/jacques/Documents/Development/Ethyme/build/Release/moc_channelmanager.o home/jacques/Documents/Development/Ethyme/build/Release/moc_usermanager.o home/jacques/Documents/Development/Ethyme/build/Release/moc_websocketmanager.o   /home/jacques/Qt/5.14.1/gcc_64/lib/libQt5Widgets.so /home/jacques/Qt/5.14.1/gcc_64/lib/libQt5Gui.so /home/jacques/Qt/5.14.1/gcc_64/lib/libQt5Sql.so /home/jacques/Qt/5.14.1/gcc_64/lib/libQt5WebSockets.so /home/jacques/Qt/5.14.1/gcc_64/lib/libQt5Network.so /home/jacques/Qt/5.14.1/gcc_64/lib/libQt5Core.so -lGL -lpthread   
    /usr/bin/ld: attempted static link of dynamic object `/home/jacques/Qt/5.14.1/gcc_64/lib/libQt5Widgets.so'
    Makefile:395: recipe for target 'Ethyme' failed
    collect2: error: ld returned 1 exit status
    make: *** [Ethyme] Error 1
    23:13:31: Le processus "/usr/bin/make" s'est terminé avec le code 2.
    Erreur lors de la compilation/déploiement du projet Ethyme (kit : Desktop Qt 5.14.1 GCC 64bit)
    When executing step "Make"
    

    I can't see what I have done wrong, could you help me please ?


  • Qt Champions 2019

    @Charlie_Billy You did not compile Qt statically.
    As the error states you can't use a shared lib to link statically.


  • Lifetime Qt Champion

    Hi
    Static linking of Qt requires a license
    and that you also build a static Qt version to link against. ( use as a new kit)


Log in to reply