andschi
andschi

Reputation: 31

How to configure a compiler in qmake

I am having issues configuring my qmake project to build/compile the same way as a command in the console. The working command to compile from console is:

g++ main.cpp -std=c++11 -luWS -lz -lssl

The flags are necessary to resolve some undefined references. Now I set up my .pro-file as follows

QT += core
QT -= gui
TARGET = car_mpc_ex
CONFIG += console
CONFIG -= app_bundle
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -luWS
QMAKE_CXXFLAGS += -lz
QMAKE_CXXFLAGS += -lssl
SOURCES +=
    main.cpp
    [...]
DISTFILES +=

HEADERS +=
    [...]

Rebuild all in QT Creator and the undefined references, solved when building in the console, are not solved... Somehow my flags are ignored?

Upvotes: 2

Views: 1804

Answers (1)

alexisdm
alexisdm

Reputation: 29886

QMAKE_CXXFLAGS is used for compiler flags whereas the libraries should be specified as linker flags. This is done through the LIBS variable (or the equivalent with the QMAKE_ prefix QMAKE_LIBS that you shouldn't need to use).

Also, the C++11 option has to be specified for both the compiler and the linker, but you can use qmake CONFIG variable to handle it in a more portable way:

CONFIG += c++11

Upvotes: 2

Related Questions