[SOLVED]QMAKE_CXXFLAGS += -static doesn't work
-
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.oI 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 guiQMAKE_CXXFLAGS += -static
QMAKE_CFLAGS = -staticSOURCES += 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.
-
Hi,
IIRC, -static is a linker flag, so you might want to try to add it to QMAKE_LFLAGS_RELEASE/QMAKE_LFLAGS.