All screenshots are clickable.
For certain purposes, it is very beneficial to use OpenMP (shared memory parallelization) for the development.
This page covers the necessary steps to use OpenMP in Xcode (via Clang compiler).
The Clang compiler that is installed on Mac with Xcode does not have all the necessary features (at least at the moment of this post publication). I suggest installation of llvm compiler via Homebrew.
- Install Homebrew if it is not installed on your Mac machine.
- Install llvm by pasting the following command in your Terminal:
brew install llvm
The following steps will be explained based on the “dummy project”; however, it should work for the existing project as well. The following code example is a standard one-thread HelloWorld.
#include <iostream> int main(int argc, const char * argv[]) { std::cout << "Greetings from thread 1"<<std::endl; return 0; }
- Specify a user-defined setting CC with the following value /usr/local/opt/llvm/bin/clang
(If Homebrew changes the location of the llvm installation, the value of the user-defined setting CC has to be changed accordingly.)
In order to do that: - Search for the setting Enable Modules (C and Objective-C) and switch it from Yes to No
- Add to the Library Search Paths the value /usr/local/opt/llvm/lib to allow for the precompiled libraries (for example, libiomp5) to be dynamically linked to your executable.
- Add to the Header Search Paths the value /usr/local/opt/llvm/lib/clang/4.0.1/include to allow inclusion of headers provided by llvm installation (for example, omp.h). Note, the installed version of Clang compiler might be different, so the value of the Header Search Path should be changed accordingly.
- Add the -fopenmp compilation flag to Other C Flags
- Link llvm OpenMP library dynamically to your executable. To do that:
- Select Build Phases -> Link Binary With Libraries options in the main Xcode window
- Open a Finder window and select Go To Folder option from the main menu.
- Navigate to /usr/local/opt/llvm/lib/ folder and select libiomp5.dylib file.
- Drag it to Xcode main window into the Add Frameworks and Libraries Here
- Select Build Phases -> Link Binary With Libraries options in the main Xcode window
Now the code should compile successfully, but already with llvm-provided Clang compiler.
Slightly editing the code to demonstrate that OpenMP is actually active:
#include <iostream> #include "omp.h" int main(int argc, const char * argv[]) { #pragma omp parallel #pragma omp critical std::cout << "Greetings from thread "<<omp_get_thread_num()<<std::endl; return 0; }
Now the code greets us from all the threads (omp critical section is used so that the output is not “scrambled”)
The number of threads being used is usually controlled via environmental variable that can be edited via Terminal:
export OMP_NUM_THREADS=8
Great article!
I suffered for a whole day to get OMP work in my Xcode project but this article solved it in 10 minutes.
Thank You!
R.
When I try to compile the given code:
#include
#include “omp.h”
int main(int argc, const char * argv[]) {
#pragma omp parallel
#pragma omp critical
std::cout << "Greetings from thread "<<omp_get_thread_num()<<std::endl;
return 0;
}
It gives me the error:
Undefined symbols for architecture x86_64:
"_omp_get_thread_num", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestions? Thank you.
It seems to me that the libiomp5.dylib was not linked to your executable. As it is not the compiler error, but the linker one. I suggest you check if the linker adds the libiomp5.dylib to your executable and if it does not, the article seems to address it in step 8.
Thanks a lot for your info. I’ve met an error by following your steps “Cannot specify -o when generating multiple output files”. Is there any suggestion? Thank you.
Hello and thanks for your info … but, unfortunately I get the same error message:
“Cannot specify -o when generating multiple output files”
I have the following installation:
llvm 5.0.1
High Sierra 10.13.2
Xcode Version 9.2
I am not an expert but maybe you could have a short look on the calling command and the error message:
Command:
CompileC /Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/Objects-normal/x86_64/main.o threadTest/main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/daniel/src/threadTest/threadTest
export LANG=en_US.US-ASCII
/usr/local/opt/llvm/bin/clang -x c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu++14 -stdlib=libc++ -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.13 -g -fvisibility-inlines-hidden -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wunguarded-availability -index-store-path /Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Index/DataStore -iquote /Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/threadTest-generated-files.hmap -I/Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/threadTest-own-target-headers.hmap -I/Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/threadTest-all-target-headers.hmap -iquote /Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/threadTest-project-headers.hmap -I/Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Products/Debug/include -I/usr/local/opt/llvm/lib/clang/4.0.1/include -I/Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/DerivedSources/x86_64 -I/Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/DerivedSources -F/Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Products/Debug -fopenmp -MMD -MT dependencies -MF /Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/Objects-normal/x86_64/main.d –serialize-diagnostics /Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/Objects-normal/x86_64/main.dia -c /Users/daniel/src/threadTest/threadTest/threadTest/main.cpp -o /Users/daniel/Library/Developer/Xcode/DerivedData/threadTest-csrvzfdfenfcyyeqpmstfejxmhpl/Build/Intermediates.noindex/threadTest.build/Debug/threadTest.build/Objects-normal/x86_64/main.o
Error Message:
clang-5.0: error: cannot specify -o when generating multiple output files
try this solution: https://stackoverflow.com/questions/46527662/xcode-9-clang-error-cannot-specify-o-when-generating-multiple-output-files
This link solved problem.
http://danlec.com/st4k#questions/46765974
[…] http://antonmenshov.com/2017/09/09/clang-openmp-setup-in-xcode/ […]
I went through these steps and xcode is giving me an error of omp.h file not found. Any help would be much appreciated.
Hi Anthony,
Can you please make sure that you have done Step 6?
omp.h is supposed to be in /usr/local/opt/llvm/lib/clang/4.0.1/include
(maybe you have a different version of clang, then the path will slightly change).
Make sure the file is there and you have done Step 6 of the instruction.
There is an error in step 8c. The name of the file is not libimpl5.dylib; it is libiomp5.dylib, as the picture shows. Other than that, it worked perfectly! Thanks a lot, Mr. Menshov.
Thanks a lot for pointing out the mistake! It is fixed now.
Thanks for this article!
Thanks for putting this together. For some reason when I try to compile the unedited code after step 8. I get an error saying :
error: can’t exec ‘ /usr/local/opt/llvm/bin/clang’ (No such file or directory)
Command /usr/local/opt/llvm/bin/clang failed with exit code 71
Could this have something to do with me running OSX 10.10.5
Thanks for the help.
A bit strange. Can you try to run the following command in your terminal:
xcode-select –install
This might help.
I just had the same issue, and it was due to a stray space that I had copied in front of /usr. Just delete that and you’re golden!
That should be solving Jacob’s problem. I did not notice that there is a space before /usr inside of the quotation marks!
how will this work for an automated build? I am using VSTS to do the iOS build but it obviously doesn’t like /usr/local/ path.
Sorry to say, have no idea and no experience using automated build and continuous integration in Xcode.
Is it possible to use this when building for iOS? When I follow the instructions, it says
ld: warning: URGENT: building for iOS simulator, but linking against dylib (/usr/local/Cellar/llvm/6.0.0/lib/libomp.dylib) built for OSX. Note: This will be an error in the future.
That dylib is built only for 64-bit macOS. Where would I be able to find OpenMP library builds for iOS and the simulator?
The build log indicates that compiling sources uses the HomeBrew-installed clang binary, but when linking, it uses /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
Hmm. I have zero knowledge about how/if OpenMP works on iOS. But you certainly cannot link your executable to libomp.dylib for Mac.
I’ve followed every step but I’m still getting the same error :
Apple LLVM 9.0 error
> Unsupported option ‘-fopenmp’
Does anyone ever encoutered this error of anyone would have any clues on how to build my project ?
Thanks.
If this could help any way :
CompileC /Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso/GraphCuts.build/Release/graph_cuts_perso.build/Objects-normal/x86_64/maxflow.o GraphCutsPerso/maxflow.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/CharlyGirot/Documents/CPE/GraphCuts/Sources
export LANG=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O3 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DCMAKE_INTDIR=\”Release\” -DCORRECTION -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.13 -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -I/Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso/Release/include -I/Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso -isystem /usr/local/include -isystem /usr/local/include/opencv -I/Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso/GraphCuts.build/Release/graph_cuts_perso.build/DerivedSources/x86_64 -I/Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso/GraphCuts.build/Release/graph_cuts_perso.build/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -F/Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso/Release -DNDEBUG -Wall -Wextra -std=c++11 -Wno-comment -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -fopenmp -MMD -MT dependencies -MF /Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso/GraphCuts.build/Release/graph_cuts_perso.build/Objects-normal/x86_64/maxflow.d –serialize-diagnostics /Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso/GraphCuts.build/Release/graph_cuts_perso.build/Objects-normal/x86_64/maxflow.dia -c /Users/CharlyGirot/Documents/CPE/GraphCuts/Sources/GraphCutsPerso/maxflow.cpp -o /Users/CharlyGirot/Documents/CPE/GraphCuts/build/GraphCutsPerso/GraphCuts.build/Release/graph_cuts_perso.build/Objects-normal/x86_64/maxflow.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
tells me that you are still using the built-in XCode clang instead of a custom one that is suggested to install in the post.I did everything as you said, the omp.h error is not there anymore, but I’m having this problem now:
clang-6.0: error: cannot specify -o when generating multiple output files
Can anyone help me. I’m in a kind of a hurry
I think someone already had this problem in this thread and this was a solution that worked.
I did everything as shown here, it worked perfect, then I try include somethings to make opengl work, after that it hasn’t worked again, I undid everything, and it’s still not working
I am getting this error
Appel LLVM 9.0 Error
Command usr/local/opt/llvm/bin/clang failed with exit code 71
Help Please
Hmm, it seems that for some reason XCode again tries to run Apple version of clang instead of the one you’ve just installed. I don’t know why is this happening, but you should definitely dig in that direction.
Worked Perfect! Thumbs Up!
I did everything as you said
and getting these errors after compilation
kindly have a look.
Semantic Issue Group
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdint:158:8: No member named ‘uint8_t’ in the global namespace
/Users/umar/Desktop/IITI 1st Sem/Advance Algorithm 3.0/Parallel Algo/ParallelProgramming/parallelcpp/parallelcpp/main.cpp:9:10: In file included from /Users/umar/Desktop/IITI 1st Sem/Advance Algorithm 3.0/Parallel Algo/ParallelProgramming/parallelcpp/parallelcpp/main.cpp:9:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:642:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:642:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:203:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:203:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdint:159:8: No member named ‘uint16_t’ in the global namespace
/Users/umar/Desktop/IITI 1st Sem/Advance Algorithm 3.0/Parallel Algo/ParallelProgramming/parallelcpp/parallelcpp/main.cpp:9:10: In file included from /Users/umar/Desktop/IITI 1st Sem/Advance Algorithm 3.0/Parallel Algo/ParallelProgramming/parallelcpp/parallelcpp/main.cpp:9:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:642:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:642:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:203:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:203:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdint:160:8: No member named ‘uint32_t’ in the global namespace
/Users/umar/Desktop/IITI 1st Sem/Advance Algorithm 3.0/Parallel Algo/ParallelProgramming/parallelcpp/parallelcpp/main.cpp:9:10: In file included from /Users/umar/Desktop/IITI 1st Sem/Advance Algorithm 3.0/Parallel Algo/ParallelProgramming/parallelcpp/parallelcpp/main.cpp:9:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:10: In file included from
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:642:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:642:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:203:10: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:203:
Apple LLVM 9.0 Error Group
Too many errors emitted, stopping now
It seems like you are still using Apple Clang, not the newly installed Clang.
CompileC Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/Objects-normal/x86_64/main.o parallelcpp/main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
cd “/Users/umar/Desktop/IITI 1st Sem/Advance Algorithm 3.0/Parallel Algo/ParallelProgramming/parallelcpp”
export LANG=en_US.US-ASCII
/usr/local/Cellar/llvm/6.0.1/lib/clang -x c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu++14 -stdlib=libc++ -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.13 -g -fvisibility-inlines-hidden -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wunguarded-availability -index-store-path /Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Index/DataStore -iquote /Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/parallelcpp-generated-files.hmap -I/Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/parallelcpp-own-target-headers.hmap -I/Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/parallelcpp-all-target-headers.hmap -iquote /Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/parallelcpp-project-headers.hmap -I/Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Products/Debug/include -I/usr/local/Cellar/llvm/6.0.1/lib/clang/6.0.1/include -I/Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/DerivedSources/x86_64 -I/Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/DerivedSources -F/Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Products/Debug -fopenmp -MMD -MT dependencies -MF /Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/Objects-normal/x86_64/main.d –serialize-diagnostics /Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/Objects-normal/x86_64/main.dia -c /Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/parallelcpp/main.cpp -o /Users/umar/Desktop/IITI\ 1st\ Sem/Advance\ Algorithm\ 3.0/Parallel\ Algo/ParallelProgramming/parallelcpp/Build/Intermediates.noindex/parallelcpp.build/Debug/parallelcpp.build/Objects-normal/x86_64/main.o
error: can’t exec ‘/usr/local/Cellar/llvm/6.0.1/lib/clang’ (Permission denied)
I’ve no idea why this pop up “Command /usr/local/opt/llvm/bin/clang failed with exit code 1”
Do somebody else know how to solve it?
Ld /Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Products/Debug/openmp normal x86_64
cd /Users/henrychung/Desktop/506/openmp
export MACOSX_DEPLOYMENT_TARGET=10.13
/usr/local/opt/llvm/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -L/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Products/Debug -L/usr/local/opt/llvm/lib -F/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Products/Debug -filelist /Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/openmp.LinkFileList -mmacosx-version-min=10.13 -Xlinker -object_path_lto -Xlinker /Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/openmp_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -liomp5 -Xlinker -dependency_info -Xlinker /Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/openmp_dependency_info.dat -o /Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Products/Debug/openmp
duplicate symbol _main in:
/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/main-13783D52D2498F25.o
/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/main-3CFADB683BB1FC2B.o
duplicate symbol _printMessageWithtime in:
/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/main-13783D52D2498F25.o
/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/main-3CFADB683BB1FC2B.o
duplicate symbol _main in:
/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/main-13783D52D2498F25.o
/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/main-E2F1C9D337857A3E.o
duplicate symbol _printMessageWithtime in:
/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/main-13783D52D2498F25.o
/Users/henrychung/Library/Developer/Xcode/DerivedData/openmp-etlfjhrnoihxygaqumvimleoerea/Build/Intermediates/openmp.build/Debug/openmp.build/Objects-normal/x86_64/main-E2F1C9D337857A3E.o
ld: 4 duplicate symbols for architecture x86_64
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
Command /usr/local/opt/llvm/bin/clang failed with exit code 1
Did you try a couple of ideas proposed by other commenters with similar troubles?
Hi Anton,
Thanks for such a detailed and clear tutorial!
Im getting a Xcode error saying that “could not find OpenMP”, even tough is installed:
https://gyazo.com/2033d8d614a42b8b3bb85325cc59f34f
Any clue what is wrong?
Appreciate if you can help! : )
Great post.
FYI, in Xcode 10.2, I received error:
> Unknown argument: ‘-index-store-path’
That was fixed by setting “Enable Index-While-Building Functionality” to “No” in “Build Settings”.
Thanks Rob, you are great.
Thanks bro! you are awesome!
Hi Anton,
I have a problem in the step 8. c)
I don’t have the file libiomp5.dylib
Can you help me?
brew install libomp – check exactly where Homebrew installed your library and add references to xcode
My home-brew install LLVM downloaded version 8.0.1. There was no libiomp5.dylib in the installation, but there was libomp.dylib so I used that. Hope this helps you.
[…] I was trying to use openMP on XCode-9 on Mac-OS Sierra 10.13.4 and I followed these steps : [http://antonmenshov.com/2017/09/09/clang-openmp-setup-in-xcode/][1] […]
[…] Clang + OpenMP Setup in Xcode. The steps are […]
Hello, Anton.
Thank you a lot for your tutorial!
In process of installation I get:
1. Unknown argument: ‘-index-store-path’
That was fixed by setting “Enable Index-While-Building Functionality” to “No” in “Build Settings”.
2. Lack of file “libiomp5.dylib”, it was changed to “libomp.dylib”
Please update this moments in your tutorial!
I’m on Xcode 11 and llvm version 10.0.0, and I had exactly these two problems. Unfortunately I didn’t see this comment before I came here to comment it myself, but these two fixes worked for me!
Thanks a lot! This solution is quite useful to me!
[…] I was trying to use openMP on XCode-9 on Mac-OS Sierra 10.13.4 and I followed these steps : [http://antonmenshov.com/2017/09/09/clang-openmp-setup-in-xcode/][1] […]
[…] Clang + OpenMP Setup in Xcode. The steps are […]
Thanks for sharing this awesome explanations that really helps.
Hi Anton. Thanks for detailed description. Plus one detail: “Build Setting -> Enable Index-While-Building Functionality” must switch in “No” position, at least in XCode 11.4 .
[…] http://antonmenshov.com/2017/09/09/clang-openmp-setup-in-xcode/ […]
I am tearing my hair out trying to get this to work after being forced to move to Xcode 8.2.1 on OS X 10.11.16. These instructions worked easily on my old Xcode setup (4.6?) on 10.6.8 where I installed an up-to-date clang via MacPorts. Now, I have done the same thing on this setup but whatever I do the compile works fine but it always refuses to link, with this message:
ld: library not found for -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have:
– added used-defined CC and LD for the external compiler (/opt/local/bin/clang -v -> clang version 9.0.1 Target: x86_64-apple-darwin15.6.0 Thread model: posix InstalledDir: /opt/local/libexec/llvm-9.0/bin)
– added search paths for the omp headers and library
– added -fopenmp as a compile flag
– added -lomp and (following other advice) just the full path to the library “/opt/local/lib/libomp” as linker flags
– added the library to “Build Phases” link binary with libraries section
– also cleaned, deleted the derived data and restarted Xcode
None of these individually or in combination will make it link.
In case there is some useful information in the error output which others will understand better than I do, here it is:
Ld /Users/mwh/Library/Developer/Xcode/DerivedData/OMP-2020-guvtozczrcqybqabqubwxlevftiv/Build/Products/Debug/OMP-2020 normal x86_64
cd /Users/mwh/Desktop/OMP-2020
export MACOSX_DEPLOYMENT_TARGET=10.11
/opt/local/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -L/Users/mwh/Library/Developer/Xcode/DerivedData/OMP-2020-guvtozczrcqybqabqubwxlevftiv/Build/Products/Debug -L/opt/local/lib -F/Users/mwh/Library/Developer/Xcode/DerivedData/OMP-2020-guvtozczrcqybqabqubwxlevftiv/Build/Products/Debug -filelist /Users/mwh/Library/Developer/Xcode/DerivedData/OMP-2020-guvtozczrcqybqabqubwxlevftiv/Build/Intermediates/OMP-2020.build/Debug/OMP-2020.build/Objects-normal/x86_64/OMP-2020.LinkFileList -mmacosx-version-min=10.11 -Xlinker -object_path_lto -Xlinker /Users/mwh/Library/Developer/Xcode/DerivedData/OMP-2020-guvtozczrcqybqabqubwxlevftiv/Build/Intermediates/OMP-2020.build/Debug/OMP-2020.build/Objects-normal/x86_64/OMP-2020_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate /opt/local/lib/libomp -lomp -weak_framework Accelerate -Xlinker -dependency_info -Xlinker /Users/mwh/Library/Developer/Xcode/DerivedData/OMP-2020-guvtozczrcqybqabqubwxlevftiv/Build/Intermediates/OMP-2020.build/Debug/OMP-2020.build/Objects-normal/x86_64/OMP-2020_dependency_info.dat -o /Users/mwh/Library/Developer/Xcode/DerivedData/OMP-2020-guvtozczrcqybqabqubwxlevftiv/Build/Products/Debug/OMP-2020
Please help!
I am having trouble here. Please help.
OMP: Error #178: Function Can’t open SHM2 failed:
OMP: System error #1: Operation not permitted
[…] 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 […]
After a couple of hours dealing with my silly mistakes. I am stuck here “OMP: Error #178: Function Can’t open SHM2 failed:”
Thank you so much for your effort! This article has saved my life!