您的位置:首页 > 产品设计 > 产品经理

Mac os 使用brew 安装 clang-opm

2016-08-26 13:14 1876 查看
地址 https://clang-omp.github.io/ 
**使用brew安装**
Using clang-omp with Xcode
Instructions are provided by Sebastian Stenzel.
Install clang-omp using homebrew: brew install clang-omp.
Create a new Xcode project.
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.
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.

**源代码安装** http://clang.llvm.org/get_started.html 
On Unix-like Systems
If you would like to check out and build Clang, the current procedure is as follows:

Get the required tools.
See Getting Started with the LLVM System - Requirements.
Note also that Python is needed for running the test suite. Get it at: http://www.python.org/download Standard build process uses CMake. Get it at: http://www.cmake.org/download Check out LLVM:
Change directory to where you want the llvm directory placed.
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
Check out Clang:
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../..
Check out extra Clang tools: (optional)
cd llvm/tools/clang/tools
svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
cd ../../../..
Check out Compiler-RT (optional):
cd llvm/projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd ../..
Check out libcxx: (only required to build and run Compiler-RT tests on OS X, optional otherwise)
cd llvm/projects
svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
cd ../..
Build LLVM and Clang:
mkdir build (in-tree build is not supported)
cd build
cmake -G "Unix Makefiles" ../llvm
make
This builds both LLVM and Clang for debug mode.
Note: For subsequent Clang development, you can just run make clang.
CMake allows you to generate project files for several IDEs: Xcode, Eclipse CDT4, CodeBlocks, Qt-Creator (use the CodeBlocks generator), KDevelop3. For more details see Building LLVM with CMake page.
If you intend to use Clang's C++ support, you may need to tell it how to find your C++ standard library headers. In general, Clang will detect the best version of libstdc++ headers available and use them - it will look both for system installations of libstdc++ as well as installations adjacent to Clang itself. If your configuration fits neither of these scenarios, you can use the -DGCC_INSTALL_PREFIX cmake option to tell Clang where the gcc containing the desired libstdc++ is installed.
Try it out (assuming you add llvm/build/bin to your path):
clang --help
clang file.c -fsyntax-only (check for correctness)
clang file.c -S -emit-llvm -o - (print out unoptimized llvm code)
clang file.c -S -emit-llvm -o - -O3
clang file.c -S -O3 -o - (output native machine code)
If you encounter problems while building Clang, make sure that your LLVM checkout is at the same revision as your Clang checkout. LLVM's interfaces change over time, and mismatched revisions are not expected to work together.

**使用brew安装问题解决**
问题:
**➜  ~ brew install clang-omp**
Error: You must `brew link cmake` before clang-omp can be installed

解决:
**➜  ~ brew link --force cmake**
Linking /usr/local/Cellar/cmake/3.4.1...
Error: Could not symlink bin/ccmake
Target /usr/local/bin/ccmake
already exists. You may want to remove it:
rm '/usr/local/bin/ccmake'

To force the link and overwrite all conflicting files:
brew link --overwrite cmake

To list all files that would be deleted:
brew link --overwrite --dry-run cmake
**➜  ~   brew link --overwrite cmake**
Linking /usr/local/Cellar/cmake/3.4.1... 28 symlinks created
**➜  ~ brew install clang-omp**
==> Installing dependencies for clang-omp: libiomp
==> Installing clang-omp dependency: libiomp
==> Downloading https://homebrew.bintray.com/bottles/libiomp-20150701.el_capitan[/code] 
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  brew clang xcode mac os