I can't use Openmp in xcode 9

"Hi!


I'm trying use openmp with xcode 9 using c++. I did this steps.


  1. Install clang-omp using homebrew:
    brew install llvm
    .
  2. Add llvm binaries to your path using :
    echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
    .
  3. Create a new Xcode project.
  4. Under Build Settings
    • Add a new user-defined setting CC with the value
      /usr/local/bin/clang-omp
    • Add
      -fopenmp
      to Other C Flags
    • Add
      /usr/local/include
      to Header Search Paths
    • Set Enable Modules (C and Objective-C) to
      No
      .
  5. Under Build Phases

    Add

    /usr/local/lib/libiomp5.dylib
    to Link Binary With Libraries

Done. You can now

#include <libiomp/omp.h>

and start using

#pragma omp ...

in your source code.


I checked all directories and files and all it exits, but when i try include the library <libiomp/omp.h> xcode say me " 'libiomp/omp.h' file not found ". And when i run the program i have this error. Apple LLVM 9 error: cannot specify -o when generating multiple output files:


CompileC /Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/Objects-normal/x86_64/main.o nasteroid2-par/main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler

cd "/Users/Goh/Documents/Universidad/Curso 2017-2018/1º Cuatrimestre/Arquitectura de Computadores/Practicas/Asteroides/nasteroid2-par"

export LANG=en_US.US-ASCII

/usr/local/bin/clang-omp -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/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Index/DataStore -iquote /Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/nasteroid2-par-generated-files.hmap -I/Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/nasteroid2-par-own-target-headers.hmap -I/Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/nasteroid2-par-all-target-headers.hmap -iquote /Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/nasteroid2-par-project-headers.hmap -I/Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Products/Debug/include -I/usr/local/include -I/Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/DerivedSources/x86_64 -I/Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/DerivedSources -F/Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Products/Debug -fopenmp -MMD -MT dependencies -MF /Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/Objects-normal/x86_64/main.d --serialize-diagnostics /Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/Objects-normal/x86_64/main.dia -c /Users/Goh/Documents/Universidad/Curso\ 2017-2018/1º\ Cuatrimestre/Arquitectura\ de\ Computadores/Practicas/Asteroides/nasteroid2-par/nasteroid2-par/main.cpp -o /Users/Goh/Library/Developer/Xcode/DerivedData/nasteroid2-par-fpsliejrfjqqtjdzzrhglgofpahg/Build/Intermediates.noindex/nasteroid2-par.build/Debug/nasteroid2-par.build/Objects-normal/x86_64/main.o

clang-5.0: error: cannot specify -o when generating multiple output files


Please could someone help me? Thank you so much

Replies

Hi Goh23,

I'm facing same error. Would you please share how you solved the problem!

I fix that problem by changing some settings:

In build settings > build options > Enable Index-While-Building Functionality to No

Any idea if OpenMP works in XCode 10? It would appear Apple clang is drifting quite far behind the LLVM community. It is getting pretty late for Apple to offer a reliable OpenMP capability.