Reputation: 376
I'm trying to introduce some OMP parallelization into my C++ Qt application and I'm failing to compile it under macOS. Colleagues are using Windows or Linux and everything is working fine for them. What do I need to write in Qt's .pro-file and do in my system?
None of the similar questions on this or any other site solved my problem. I'm usually compiling with Apple-provided clang, but there seems to be no OMP-support for that. So I've installed clang with llvm via homebrew, set up my kit in Qt accordingly and also tried every permutation of following lines in my .pro-file:
QMAKE_CXXFLAGS += -fopenmp
QMAKE_LFLAGS += -fopenmp
QMAKE_LINK = /usr/local/Cellar/llvm/9.0.0/bin/clang-9
QMAKE_CC = /usr/local/Cellar/llvm/9.0.0/bin/clang-9
QMAKE_CXX = /usr/local/Cellar/llvm/9.0.0/bin/clang-9
LIBS += -fopenmp
LIBS += -L/usr/local/lib/
With all of that I get many weird problems leading to symbol(s) not found for architecture x86_64
, also without any of the lines pointing to clang-9, but still this is the best I could achieve.
Without the last line I get library not found for -lomp
, without the QMAKE_LINK line unsupported option '-fopenmp'
.
None of the possible solutions I found online for these error messages helped either.
libomp.dylib
is installed and linked into /usr/local/lib
.
I also tried the whole process with GCC, but without success as well.
This is bugging me for three days already and I really hope this can be solved. Can't be that hard, can it? A solution that isn't messing with the compatibility on Windows/Linux would be optimal.
PS: I'm using qmake via the play button in Qt creator.
Reference: 1, 2, 3, 4 and many others.
Upvotes: 2
Views: 973
Reputation: 6441
AppleClang should work just fine. Be sure to call the preprocessor to handle OMP via the .pro
file.
macx: {
QMAKE_CXXFLAGS += -Xpreprocessor -fopenmp -lomp -I/usr/local/include
}
macx: {
QMAKE_LFLAGS += -lomp
}
macx: {
LIBS += -L /usr/local/lib /usr/local/lib/libomp.dylib
}
Upvotes: 4