Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [SOLVED]QMAKE_CXXFLAGS += -static doesn't work
Forum Update on Tuesday, May 27th 2025

[SOLVED]QMAKE_CXXFLAGS += -static doesn't work

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 4.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jamj2000
    wrote on 13 Feb 2013, 20:44 last edited by
    #1

    I trying to create a statically linked application.

    For simplicity I created a Non-Qt Project --> Plain C Text like this:

    @#include <stdio.h>

    int main(void)
    {
    printf("Hello World!\n");
    return 0;
    }@

    If I compile and link in a terminal:

    gcc -static -c -o main main.c

    or if I do in 2 steps:

    gcc -static -c -o main.o main.c
    g++ -static -o main main.o

    I get a statically linked application, but if I do in QtCreator it doesn't work.
    My .pro file is:

    TEMPLATE = app
    CONFIG += console
    CONFIG -= qt
    QT -= core gui

    QMAKE_CXXFLAGS += -static
    QMAKE_CFLAGS = -static

    SOURCES += main.c

    and the senteces that make execute are:

    gcc -c -static -O2 -Wall -W -DQT_WEBKIT -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -o main.o main.c
    g++ -m64 -Wl,-O1 -o prueba main.o

    ¿Why it doesn't appear option -static in g++?

    I also tried with QMAKE_CXXFLAGS_RELEASE = -static and QMAKE_CXXFLAGS_DEBUG = -static with identical result.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Feb 2013, 08:57 last edited by
      #2

      Hi,

      IIRC, -static is a linker flag, so you might want to try to add it to QMAKE_LFLAGS_RELEASE/QMAKE_LFLAGS.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jamj2000
        wrote on 14 Feb 2013, 18:06 last edited by
        #3

        Thank you so much, SGaist.

        It works if my .pro file is:

        TEMPLATE = app
        CONFIG += console
        CONFIG -= qt
        QT -= core gui

        QMAKE_CFLAGS = -static
        QMAKE_LFLAGS += -static

        SOURCES += main.c

        1 Reply Last reply
        0

        1/3

        13 Feb 2013, 20:44

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved