gtest with xcode. error: d: framework not found gtest - c++

I follow the instruction and the ans to setup gtest for xcode. But
it still doesn't work and i got the error below:
Ld
/Users/xiaxin/Library/Developer/Xcode/DerivedData/Calculator-cchvzojufxzxgfdevhkifabakxpl/Build/Products/Debug/Tests
normal x86_64 cd /Users/xiaxin/Documents/xCode/Calculator export
MACOSX_DEPLOYMENT_TARGET=10.10
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-L/Users/xiaxin/Library/Developer/Xcode/DerivedData/Calculator-cchvzojufxzxgfdevhkifabakxpl/Build/Products/Debug
-L/usr/local/lib -F/Users/xiaxin/Library/Developer/Xcode/DerivedData/Calculator-cchvzojufxzxgfdevhkifabakxpl/Build/Products/Debug
-filelist /Users/xiaxin/Library/Developer/Xcode/DerivedData/Calculator-cchvzojufxzxgfdevhkifabakxpl/Build/Intermediates/Calculator.build/Debug/Tests.build/Objects-normal/x86_64/Tests.LinkFileList
-mmacosx-version-min=10.10 -lgtest -stdlib=libc++ -framework gtest -Xlinker -dependency_info -Xlinker /Users/xiaxin/Library/Developer/Xcode/DerivedData/Calculator-cchvzojufxzxgfdevhkifabakxpl/Build/Intermediates/Calculator.build/Debug/Tests.build/Objects-normal/x86_64/Tests_dependency_info.dat
-o /Users/xiaxin/Library/Developer/Xcode/DerivedData/Calculator-cchvzojufxzxgfdevhkifabakxpl/Build/Products/Debug/Tests
ld: framework not found gtest clang: error: linker command failed with
exit code 1 (use -v to see invocation)

You need to add the GTest library to your library path. You can accomplish this on the commandline by setting -L/path/to/gtest

Related

can't link with a main executable file '/usr/local/bin/lua' for architecture x86_64

I'm attempting to make a dylib using multiple files with the command:
g++ -std=c++11 rewrite.cpp Utilities/*.cpp -fpermissive -I /Users/x/Desktop/lua-5.1 -L/Users/x/Desktop/libs /usr/local/bin/lua -lm -ldl -o /Users/x/Desktop/Code/Result.dylib -v
However I'm encountering the error: ld: can't link with a main executable file '/usr/local/bin/lua' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

ld: library not found for -lcrypto

I am trying to run the http://iphonedevwiki.net/index.php/Theos/Setup tutorial but stuck on this step:
./make.sh
+ xcrun -sdk macosx g++ -mmacosx-version-min=10.4 -arch i386 -arch x86_64 -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/usr/include/libxml2 -Ilibplist/include -Ilibplist/libcnary/include -c -std=c++11 -o out/ldid.o ldid.cpp
+ xcrun -sdk macosx g++ -mmacosx-version-min=10.4 -arch i386 -arch x86_64 -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/usr/include/libxml2 -Ilibplist/include -Ilibplist/libcnary/include -o out/ldid out/ldid.o out/iterator.o out/list.o out/node.o out/node_iterator.o out/node_list.o out/base64.o out/bplist.o out/bytearray.o out/hashtable.o out/plist.o out/ptrarray.o out/xplist.o -x c lookup2.c -lxml2 -framework Security -lcrypto
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Could you please help?
Check if -lcrypto is installed on your system (on a Linux system, you could try calling ldconfig -p | grep libcrypto, but if you are using macOS, try to find some equivalent)
Make sure your g++ call contains proper path if this library is at some specific location that will not be searched by g++ by default.
You can read about including libraries and header files in this stack overflow topic: https://stackoverflow.com/a/6141166/4802475

Linking with LLVM LLD does not work [macos]

The following compile command with clang6.0:
LDFLAGS="-L/usr/local/opt/myllvm6.0rc1/lib -fuse-ld=lld"
CPPFLAGS="-I/usr/local/opt/myllvm6.0rc1/include -I/usr/local/opt/myllvm6.0rc1/include/c++/v1/";
clang++ -fsanitize=address $LDFLAGS $CPPFLAGS -g -v main.cpp
gives:
"/usr/local/opt/myllvm6.0rc1/bin/ld64.lld" -demangle -lto_library /usr/local/opt/myllvm6.0rc1/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o a.out -L/usr/local/opt/myllvm6.0rc1/lib /var/folders/14/rc46ppds1ms2kj_mvdcxlc040000gn/T/main-113675.o -lc++ /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib -rpath #executable_path -rpath /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin -lSystem /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin/libclang_rt.osx.a
warning: ignoring unknown argument: -no_deduplicate
warning: -sdk_version is required when emitting min version load command. Setting sdk version to match provided min version
Unable to find library for -lto_library
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
I dont understand why it cant load the /usr/local/opt/myllvm6.0rc1/lib/libLTO.dylib (it exists at this location!)
Any idea?
You are using -fuse-ld=lld which is what the LLD documentation says to do and as you can see ld64.lld is being run. However, the flag -no_deduplicate is not an lld flag; it is an OSX ld flag. The ld64.lld man page is here:
https://manpages.ubuntu.com/manpages/disco/man1/ld.lld.1.html

C++/R: clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am trying to install and run a this project. It is written in C++ and R. I follow the instructions and when I type the make command, I get this error:
R CMD SHLIB src/C/util.c src/C/factor_model_util.c src/C/pagerank.c src/C/hierarchical.c src/C/factor_model_multicontext.c src/C/factor_model_util2.cpp -o lib/c_funcs.so
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o lib/c_funcs.so src/C/util.o src/C/factor_model_util.o src/C/pagerank.o src/C/hierarchical.o src/C/factor_model_multicontext.o src/C/factor_model_util2.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -Wall -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [lib/c_funcs.so] Error 1
make: *** [c_funcs] Error 1
Here is my "clang --version" results:
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
Does anyone know what should I do? I saw the answers about xcode projects, but here I am only trying to use make for compiling.
Thanks
I had a very similar issue, and solved it by installing the newer gfortran 4.8.2. For some reason the main page links to version 4.3.2, which causes this issue (I believe because R binaries are actually built with a newer gfortran).

xcode error library not found for -lassimp

I used the method described in the answer of: https://stackoverflow.com/a/18922738/2197292
to build Assimp 3.0 on my Mac OS X 10.9. I use Xcode 5.0.2. Then I added libassimp.a to frameworks and added /usr/local/include/assimp to header search paths. Am I missing something? When I build my project I get this error:
Ld DerivedData/OpenGLGLSL5Assimp/Build/Products/Debug/OpenGLGLSL5Assimp.app/Contents/MacOS/OpenGLGLSL5Assimp normal x86_64
cd /Users/MATH/Documents/XCODE/OpenGLGLSL5Assimp
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/MATH/Documents/XCODE/OpenGLGLSL5Assimp/DerivedData/OpenGLGLSL5Assimp/Build/Products/Debug -F/Users/MATH/Documents/XCODE/OpenGLGLSL5Assimp/DerivedData/OpenGLGLSL5Assimp/Build/Products/Debug -filelist /Users/MATH/Documents/XCODE/OpenGLGLSL5Assimp/DerivedData/OpenGLGLSL5Assimp/Build/Intermediates/OpenGLGLSL5Assimp.build/Debug/OpenGLGLSL5Assimp.build/Objects-normal/x86_64/OpenGLGLSL5Assimp.LinkFileList -mmacosx-version-min=10.8 -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -lassimp -framework GLUT -framework OpenGL -framework Cocoa -Xlinker -dependency_info -Xlinker /Users/MATH/Documents/XCODE/OpenGLGLSL5Assimp/DerivedData/OpenGLGLSL5Assimp/Build/Intermediates/OpenGLGLSL5Assimp.build/Debug/OpenGLGLSL5Assimp.build/Objects-normal/x86_64/OpenGLGLSL5Assimp_dependency_info.dat -o /Users/MATH/Documents/XCODE/OpenGLGLSL5Assimp/DerivedData/OpenGLGLSL5Assimp/Build/Products/Debug/OpenGLGLSL5Assimp.app/Contents/MacOS/OpenGLGLSL5Assimp
ld: library not found for -lassimp
clang: error: linker command failed with exit code 1 (use -v to see invocation)