I am trying to use CGAL in a project. I have installed CGAL using brew:
brew install cgal
Then, I tried to run some simple code. I am trying to run the first code of this webpage:
https://doc.cgal.org/4.7-beta1/Manual/introduction.html
I have tried to compile the code using the following command:
g++ -lcgal points_and_segment.cpp -o points_and_segment
But I am getting this error:
Undefined symbols for architecture x86_64:
"boost::detail::get_tss_data(void const*)", referenced from:
boost::thread_specific_ptr<double>::get() const in points_and_segment-78cb9a.o
"boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)", referenced from:
boost::thread_specific_ptr<double>::reset(double*) in points_and_segment-78cb9a.o
boost::thread_specific_ptr<double>::~thread_specific_ptr() in points_and_segment-78cb9a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have tried to include -lboost or -lboost_thread in the command. But then I am getting the following errors:
ld: library not found for -lboost
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: library not found for -lboost_thread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have tried the same with -v. Then I get the following:
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name points_and_segment.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir /Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.0.0 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/abureyanahmed/cgal_test -ferror-limit 19 -fmessage-length 143 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/vf/b6nrfcl95l56768gldg25r1m0000gn/T/points_and_segment-c5ee94.o -x c++ points_and_segment.cpp
clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1
/usr/local/include
/Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.0.0/include
/Library/Developer/CommandLineTools/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o points_and_segment -lcgal -lboost /var/folders/vf/b6nrfcl95l56768gldg25r1m0000gn/T/points_and_segment-c5ee94.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lboost
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have looked for the cgal installation folder. It is the following path in my machine:
cd /usr/local/opt/cgal/
The folder for boost is:
cd /usr/local/opt/boost/
.brew/ INSTALL_RECEIPT.json include/ lib/
I struggled with this too. This website helped:
https://discourse.brew.sh/t/could-not-link-to-boost/2125/4
Related
Clang isn't able to find omp.h whenever I try to compile with openMP flag. Here's what I'm trying to do
clang++ -dynamiclib -I/opt/homebrew/Cellar/eigen/3.3.9/include/eigen3/ -Xpreprocessor -fopenmp -o libfoo.dylib foolibrary.cpp -lomp
Although I have omp.h in /opt/homebrew/Cellar/libomp/11.0.1/include/omp.h, while clang is in usr/bin/clang. Is there anything I need to configure so that it's able to find it?
When using brew to target the M1 natively, the brew installed clang is not in /usr/bin.
The brew instructions show that the preferred location for it is /opt/homebrew. The clang in /usr/bin is a link to the Apple command line tools one; you can see that by using -v.
$ /usr/bin/clang -v
/usr/bin/clang -v
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
To get the brew installed clang you need to follow the instructions brew gave you when you installed it :-
llvm is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.profile
For compilers to find llvm you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
Doing that resolves the include issue, but, at least for me, not the library linking one.
/opt/homebrew/opt/llvm/bin/clang -v -fopenmp hello_omp.c
clang version 11.1.0
Target: arm64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
"/opt/homebrew/Cellar/llvm/11.1.0/bin/clang-11" -cc1 -triple arm64-apple-macosx11.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello_omp.c -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-rounding-math -munwind-tables -fcompatibility-qualified-id-block-type-checking -target-cpu apple-a7 -target-feature +fp-armv8 -target-feature +neon -target-feature +crypto -target-feature +zcm -target-feature +zcz -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -fallow-half-arguments-and-returns -debugger-tuning=lldb -target-linker-version 609.8 -v -resource-dir /opt/homebrew/Cellar/llvm/11.1.0/lib/clang/11.1.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /opt/homebrew/Cellar/llvm/11.1.0/lib/clang/11.1.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -fdebug-compilation-dir /Users/jcownie/tmp -ferror-limit 19 -fmessage-length=163 -fopenmp -fopenmp-cuda-parallel-target-regions -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -o /var/folders/lt/nf3dtk8j16qfsl97d_vgv4dw000lts/T/hello_omp-bd4ce3.o -x c hello_omp.c
clang -cc1 version 11.1.0 based upon LLVM 11.1.0 default target arm64-apple-darwin20.3.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/opt/homebrew/Cellar/llvm/11.1.0/lib/clang/11.1.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /opt/homebrew/Cellar/llvm/11.1.0/lib/libLTO.dylib -no_deduplicate -dynamic -arch arm64 -platform_version macos 11.0.0 0.0.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o a.out /var/folders/lt/nf3dtk8j16qfsl97d_vgv4dw000lts/T/hello_omp-bd4ce3.o -lomp -lSystem /opt/homebrew/Cellar/llvm/11.1.0/lib/clang/11.1.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lomp
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
If you explicitly pass the recommended $LDFLAGS, then things work...
$ echo $LDFLAGS
-L/opt/homebrew/opt/llvm/lib
$ /opt/homebrew/opt/llvm/bin/clang $LDFLAGS -fopenmp hello_omp.c
/opt/homebrew/opt/llvm/bin/clang $LDFLAGS -fopenmp hello_omp.c
$ ./a.out
./a.out
Hello from thread 0
Hello from thread 5
Hello from thread 4
Hello from thread 1
Hello from thread 3
Hello from thread 2
Hello from thread 7
Hello from thread 6
$
My (hacky, but it works) solution to that has been to create my own shell scripts to invoke the compilers with the appropriate library path; you can see this hack in How to build LLVM (clang,clang++) for Apple M1?
Note that at one more point the support for OpenMP tasks was broken in LLVM when targeting the M1. (See "Crash in passing firstprivate args to tasks on Apple M1"). However, that was fixed in March 2021, so be sure to use a more recent LLVM release.
In your terminal:
brew install libomp
Then in your Makefile:
CC=clang++
FLAGS=-g -Wall -std=c++17 -arch arm64 -lomp
LDFLAGS=-L/opt/homebrew/lib
CPPFLAGS=-I/opt/homebrew/include
My Mac & clang:
clang -v
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.5.0
Thread model: posix
After I installed React-Native.
Whenever build a file through "clang", I can't execute the file.
Always I got this message when try to execute it.
dyld: mach-o, but built for simulator (not macOS)
And I found that my default compile option of clang is changed for "ios-simulator".
How to change this default option?
$ clang++ --std=c++17 --verbose test_move.cpp
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-ios9.0.0-simulator -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test_move.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -faligned-alloc-unavailable -target-sdk-version=12.2 -target-cpu core2 -dwarf-column-info -debugger-tuning=lldb -target-linker-version 450.3 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk -stdlib=libc++ -Wno-atomic-implicit-seq-cst -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-quoted-include-in-framework-header -Wno-error --std=c++17 -fdeprecated-macro -fdebug-compilation-dir /Users/user/workspace/examples -ferror-limit 19 -fmessage-length 149 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=ios-9.0.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/9k/c6qvlvt10wg3g5vyzf009lxw0000gn/T/test_move-3416bc.o -x c++ test_move.cpp
clang -cc1 version 10.0.1 (clang-1001.0.46.4) default target x86_64-apple-darwin18.5.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/Library/Frameworks"
include "..." search starts here:
include <...> search starts here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -ios_simulator_version_min 9.0.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk -o a.out /var/folders/9k/c6qvlvt10wg3g5vyzf009lxw0000gn/T/test_move-3416bc.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/lib/darwin/libclang_rt.ios.a
$
$
$ ./a.out
dyld: mach-o, but built for simulator (not macOS)
Abort trap: 6
I used brew install llvm to install LLVM 8 and I want to use the command line tools. I have set the path to the clang executable (in /usr/local/opt/llvm/bin) as suggested by Homebrew and also set LDFLAGS and CPPFLAGS as they suggest. When I compile a simple program I get
x.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
Reading the the docs for xcrun and xcode-select I feel there should be a simple way to select my LLVM toolchain but I can't figure it out. I have tried changing the TOOLCHAINS and SDKROOT with no success.
Output of clang -v -c x.c for Homebrew's llvm-8
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
"/usr/local/Cellar/llvm/8.0.0/bin/clang-8" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name x.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -ggnu-pubnames -target-linker-version 409.12 -v -coverage-notes-file /tmp/x.gcno -resource-dir /usr/local/Cellar/llvm/8.0.0/lib/clang/8.0.0 -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o x.o -x c x.c
clang -cc1 version 8.0.0 based upon LLVM 8.0.0 default target x86_64-apple-darwin18.5.0
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/Cellar/llvm/8.0.0/lib/clang/8.0.0/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
x.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
Output of system clang:
Apple LLVM version 10.0.1 (clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name x.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 450.3 -v -coverage-notes-file /tmp/x.gcno -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/include -Wno-atomic-implicit-seq-cst -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-quoted-include-in-framework-header -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o x.o -x c x.c
clang -cc1 version 10.0.1 (clang-1001.0.46.3) default target x86_64-apple-darwin18.5.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks (framework directory)
End of search list.
You should either install missing headers/libraries as noted in this question.
Alternatively, you should point clang to another 'sysroot', e.g.:
clang -isysroot `xcrun --show-sdk-path` hello.c
I have installed OpenMP and xcode-select in my macos.
$ clang-omp --version
clang version 3.5.0
Target: x86_64-apple-darwin15.4.0
Thread model: posix
$ xcode-select --version
xcode-select version 2343.
While running following pretty simple code
1 #include <omp.h>
2 #include <stdio.h>
3
4 #define n 20
5
6 int main(){
7
8 int i;
9 int tid;
10
11 omp_set_num_threads(3);
12 #pragma omp parallel for private(tid) schedule(static,1)
13
14 for (i=0; i<n; i++) {
15 tid = omp_get_thread_num();
16 printf("Thread %d executing iteration %d\n", tid, i);
17 }
18 }
I get error
$ clang-omp -openmp parallel.c -v
clang version 3.5.0
Target: x86_64-apple-darwin15.4.0
Thread model: posix
"/usr/local/Cellar/clang-omp/2015-04-01/libexec/bin/clang-3.5" -cc1 -triple x86_64-apple-macosx10.11.0 -emit-obj -mrelax-all -disable-free -main-file-name parallel.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -v -dwarf-column-info -resource-dir /usr/local/Cellar/clang-omp/2015-04-01/libexec/bin/../lib/clang/3.5.0 -fdebug-compilation-dir /Users/prayagupd/prayag.data/workspace.programming/parallel-programming/openMP -ferror-limit 19 -fmessage-length 178 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/63/jvvb4wy16gx6w76mkgsvn52m0000gn/T/parallel-32b98e.o -x c parallel.c
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target x86_64-apple-darwin15.4.0
ignoring nonexistent directory "/usr/local/Cellar/clang-omp/2015-04-01/libexec/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/Cellar/clang-omp/2015-04-01/libexec/bin/../lib/clang/3.5.0/include
/usr/local/opt/libiomp/include/libiomp
/usr/local/Cellar/clang-omp/2015-04-01/libexec/include/c++/v1
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/usr/bin/ld" -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o penmp /var/folders/63/jvvb4wy16gx6w76mkgsvn52m0000gn/T/parallel-32b98e.o -lSystem
Undefined symbols for architecture x86_64:
"_omp_get_thread_num", referenced from:
_main in parallel-32b98e.o
"_omp_set_num_threads", referenced from:
_main in parallel-32b98e.o
ld: symbol(s) not found for architecture x86_64
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)
gcc doesn't even find omp.h.
$ gcc parallel.c -fopenmp -o parallel
parallel.c:1:10: fatal error: 'omp.h' file not found
#include <omp.h>
^
1 error generated.
gcc version is
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
For your clang-omp issue, did you export the library path? ala
export DYLD_LIBRARY_PATH=(OMPLIB PATH):$DYLD_LIBRARY_PATH
Maybe you didn't install the OpenMP library from Intel? Modern clang(>3.7), that isn't packaged with OS X, now supports OpenMP out of the box.
For your gcc issue, OS X doesn't actually provide gcc, it just links it to vanilla clang. So you are trying to compile it with a compiler which doesn't support OpenMP. If you want gcc, then install it via ports or homebrew.
I’m writing some unit tests for a dynamic library on OS X. The dynamic library is in ../MathDll. The library itself is built via the following Makefile:
all: math.dylib
math.dylib: MathDll.cpp MathDll.h
clang -dynamiclib MathDll.cpp -o math.dylib
clean:
rm math.dylib
And running file math.dylib gives
math.dylib: Mach-O 64-bit dynamically linked shared library x86_64
I have a simple program, test1.cpp, that will call one of the functions from this library. I tried to compile it with
clang -I../MathDll -L../MathDll -lmath test1.cpp
but this gives me
ld: library not found for -lmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When I invoke Clang with -v, the output is
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test1.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 224.1 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0 -I ../MathDll -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir "/Users/bdesham/Projects/New GUI/math_library/osx_test" -ferror-limit 19 -fmessage-length 118 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/gc/4w1rdgzx3zz2dbxf0m_yd67c0000gn/T/test1-sL5rwc.o -x c++ test1.cpp
clang -cc1 version 5.0 based upon LLVM 3.3svn default target x86_64-apple-darwin13.0.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
../MathDll
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out -L../MathDll -lmath /var/folders/gc/4w1rdgzx3zz2dbxf0m_yd67c0000gn/T/test1-sL5rwc.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I must be doing something silly here. What do I need to do to make the linker find my library?
Your library needs to be called libmath.dylib, not just math.dylib.