Using OpenMP in Xcode 11

  c++, clang, openmp, xcode

I would like to use the OpenMP library in my c++ Xcode projects. I am using macOS Catalina 10.15.4 and Xcode 11.7. I tried to follow the instructions in http://antonmenshov.com/2017/09/09/clang-openmp-setup-in-xcode/ and setting Enable Index-While-Building Functionality to No, however when I try to compile I get the following error:

Build target learningOpenMP of project learningOpenMP with configuration Debug

Ld /Users/macbookpro/Library/Developer/Xcode/DerivedData/learningOpenMP-cnphpjmynavfyhewvufaaehlkduh/Build/Products/Debug/learningOpenMP normal x86_64 (in target ‘learningOpenMP’ from project ‘learningOpenMP’)
cd /Users/macbookpro/Desktop/Projects/cpp_tests/learningOpenMP
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.15 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -L/Users/macbookpro/Library/Developer/Xcode/DerivedData/learningOpenMP-cnphpjmynavfyhewvufaaehlkduh/Build/Products/Debug -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/learningOpenMP-cnphpjmynavfyhewvufaaehlkduh/Build/Products/Debug -filelist /Users/macbookpro/Library/Developer/Xcode/DerivedData/learningOpenMP-cnphpjmynavfyhewvufaaehlkduh/Build/Intermediates.noindex/learningOpenMP.build/Debug/learningOpenMP.build/Objects-normal/x86_64/learningOpenMP.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/macbookpro/Library/Developer/Xcode/DerivedData/learningOpenMP-cnphpjmynavfyhewvufaaehlkduh/Build/Intermediates.noindex/learningOpenMP.build/Debug/learningOpenMP.build/Objects-normal/x86_64/learningOpenMP_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -stdlib=libc++ -lomp -Xlinker -dependency_info -Xlinker /Users/macbookpro/Library/Developer/Xcode/DerivedData/learningOpenMP-cnphpjmynavfyhewvufaaehlkduh/Build/Intermediates.noindex/learningOpenMP.build/Debug/learningOpenMP.build/Objects-normal/x86_64/learningOpenMP_dependency_info.dat -o /Users/macbookpro/Library/Developer/Xcode/DerivedData/learningOpenMP-cnphpjmynavfyhewvufaaehlkduh/Build/Products/Debug/learningOpenMP

ld: library not found for -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It seems the linker is not able to find the library? Has anyone managed to use openMP in Xcode 11.7?

Source: Windows Questions C++

LEAVE A COMMENT