PDA

View Full Version : Doubt about the variable QMAKE_CXXFLAGS



Eduardo Huerta
6th May 2019, 23:24
Hi,
What do the following instructions?
win32:!win32-g++{ #?????
QMAKE_CXXFLAGS += -openmp #?????
QMAKE_LFLAGS += -openmp #?????
}else{
QMAKE_CXXFLAGS+= -fopenmp #?????
QMAKE_LFLAGS += -fopenmp #?????
}
QMAKE_CXXFLAGS is defined as:
Specifies the C++ compiler flags for building a project. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.
OpenMP (Open Multi-Processing) is an application programming interface (API) that supports multi-platform shared memory multiprocessing programming in C, C++, and Fortran.
I do not understand why in some instructions it appears -openmp and in others -fopenmp.
when is it necessary to use QMAKE_CXX and how do I know what value or variable (openmp) should I add?
Thanks.

ChrisW67
7th May 2019, 09:30
QMAKE_CXXFLAGS does not require any particular values, your C++ compiler does.
Similarly, QMAKE_LFAGS contains options needed by your linker.
This project file is attempting to cater for different environments in which it may be built and the different syntax/requirement of the compiler and linker. In this specific case it turns on compiler and linker support for OpenMP. The details of the switches accepted by your compiler/linker will be in their documentation. Whether you need them or not is driven by your project.


# This structure is called a scope in the qmake manual. It functions a little like an if-then-else statement.
# vvvvvvvvvvvvvvv
win32:!win32-g++{ # On the Windows platform (win32) and not (!) using the GNU compiler (win32-g++)
QMAKE_CXXFLAGS += -openmp # pass this option to the C++ compiler when compiling files
QMAKE_LFLAGS += -openmp # and pass this option to the linker when linking the project
} else { # On Windows with the GNU compiler and all other platforms (assuming GNU compiler)
QMAKE_CXXFLAGS+= -fopenmp # and pass this option to the linker when linking the project
QMAKE_LFLAGS += -fopenmp and pass this option to the linker when linking the project
}

Eduardo Huerta
10th May 2019, 00:29
I understand. Thank you.