I get a compile-time error in Xcode that includes this message
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This -v is evidently a command-line option. I've run into this message before and have always been at a loss as to what I can do about it and why it's included if I can't do anything about it.
How can I employ the option in Xcode to see the invocation?
You can add the -v to the "Other Linker Flags" field in the project settings. Doing so in a test project here yields the complete linker invocation:
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
-demangle
-dynamic
-arch x86_64
-macosx_version_min 10.8.0
-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
-o /Users/carl/Library/Developer/Xcode/DerivedData/example-ewesimyvcwmjptdwzbkqoasrcppe/Build/Products/Debug/example
-L/Users/carl/Library/Developer/Xcode/DerivedData/example-ewesimyvcwmjptdwzbkqoasrcppe/Build/Products/Debug
-filelist /Users/carl/Library/Developer/Xcode/DerivedData/example-ewesimyvcwmjptdwzbkqoasrcppe/Build/Intermediates/example.build/Debug/example.build/Objects-normal/x86_64/example.LinkFileList
-dependency_info /Users/carl/Library/Developer/Xcode/DerivedData/example-ewesimyvcwmjptdwzbkqoasrcppe/Build/Intermediates/example.build/Debug/example.build/Objects-normal/x86_64/example_dependency_info.dat
-lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/lib/darwin/libclang_rt.osx.a
-F/Users/carl/Library/Developer/Xcode/DerivedData/example-ewesimyvcwmjptdwzbkqoasrcppe/Build/Products/Debug
Related
I have been trying to use Clang's address code sanitizer, but the linker will not have it. The linker may be "ld", though my CMAKE settings assure me that clang is the linker.
Added -fsanitize=address to compiler and linker flags.
Error:
Undefined symbols for architecture x86_64:
___asan_after_dynamic_init
...
___asan_before_dynamic_init
...
etc.
ld: symbol(s) not found for architecture x86_64 <<<< **suspicious**
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Environment: MacOS
clang: Apple LLVM version 8.0.0 (clang-800.0.38)
cmake: 3.7.1
CMAKE_CXX_COMPILER = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (redirects to clang)
CMAKE_CXX_COMPILER_ID = Clang
Compiler Flags: -O0 -g -fsanitize=address
CMAKE_LINKER = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (redirects to clang)
CMAKE_CXX_LINK_EXECUTABLE = CMAKE_CXX_COMPILER FLAGS CMAKE_CXX_LINK_FLAGS LINK_FLAGS OBJECTS -o TARGET LINK_LIBRARIES
CMAKE_CXX_LINK_FLAGS = -Wl,-search_paths_first -Wl,-headerpad_max_install_names -fsanitize=address -v
Solution from here
Pass the -fsanitize=address flag to the linker as well as the compiler.
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
Although more a novice I try to explain my problem.
I am on a Mac and use command line to build the executable. The compiling command works successfully on Ubuntu.
cc program.o file1.o file2.o file3.o file4.o -lm -lrt -o program
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [program] Error 1
If I run with -v command I get the following:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -o program program.o file1.o file2.o file3.o file4.o -lm -lrt -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/lib/darwin/libclang_rt.osx.a
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any hint?
I found in this post what -lm -lrt mean but still could not figure out a solution.
Update 1: According to this link -lrt is not available for Mac.
Update 2: I have found two possible solutions: (a) either to remove completely the flag or (b) use the -lSystem.B instead. The real-time extensions seems to be in libSystem.B.dylib as explained here.
I want to create Xcode plugin, and I choose Xcode Plugin Template from Alcatraz, then i close project add Podfile open workspace and try to build i get ann error every time:
ld: library not found for -lDTXcodeUtils
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is a full output:
Ld /Users/jakubmazur/Library/Application\
Support/Developer/Shared/Xcode/Plug-ins/CreateFilesPlugin.xcplugin/Contents/MacOS/CreateFilesPlugin
normal x86_64
cd /Users/jakubmazur/Developer/CreateFilesPlugin
export MACOSX_DEPLOYMENT_TARGET=10.10
/Users/jakubmazur/Desktop/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-arch x86_64 -bundle -isysroot /Users/jakubmazur/Desktop/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-L/Users/jakubmazur/Library/Developer/Xcode/DerivedData/CreateFilesPlugin-dmzpluimftctcqhbkndjiknqtjnz/Build/Products/Debug
-F/Users/jakubmazur/Library/Developer/Xcode/DerivedData/CreateFilesPlugin-dmzpluimftctcqhbkndjiknqtjnz/Build/Products/Debug
-filelist /Users/jakubmazur/Library/Developer/Xcode/DerivedData/CreateFilesPlugin-dmzpluimftctcqhbkndjiknqtjnz/Build/Intermediates/CreateFilesPlugin.build/Debug/CreateFilesPlugin.build/Objects-normal/x86_64/CreateFilesPlugin.LinkFileList
-mmacosx-version-min=10.10 -ObjC -lDTXcodeUtils -lXcodeEditor -fobjc-arc -fobjc-link-runtime -framework AppKit -framework Foundation -lPods -Xlinker -dependency_info -Xlinker /Users/jakubmazur/Library/Developer/Xcode/DerivedData/CreateFilesPlugin-dmzpluimftctcqhbkndjiknqtjnz/Build/Intermediates/CreateFilesPlugin.build/Debug/CreateFilesPlugin.build/Objects-normal/x86_64/CreateFilesPlugin_dependency_info.dat
-o /Users/jakubmazur/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/CreateFilesPlugin.xcplugin/Contents/MacOS/CreateFilesPlugin
ld: library not found for -lDTXcodeUtils clang: error: linker command
failed with exit code 1 (use -v to see invocation)
Any idea what should i set to do this?
Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :osx
pod "DTXcodeUtils"
Do the following steps. Its a work around.
Remove all the scheme and add by clicking auto create schemes.(The pods schemes will be checked once its recreated, need it checked for working it).
Then remove the scheme file from copy bundle resources(is it shows an error).
Deep clean and run
Its building without any error for me, Not sure whether it shows any run time errors/ exceptions
Upgrading to Xcode 5.1 (and the most recent command line tools) has resulted in my no longer being able to build zlib. I now get the following:
gcc -dynamiclib -install_name /Users/fonnescj/Code/lib/libz.1.dylib -compatibility_version 1 -current_version 1.2.5 -arch x86_64 -I/Users/fonnescj/Code/include -I/Users/fonnescj/Code/include/freetype2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -fPIC -o libz.1.2.5.dylib adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo -lc -arch x86_64 -L/Users/fonnescj/Code/lib -lbz2 -syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L. libz.a
clang: error: unknown argument: '-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make[1]: *** [libz.1.2.5.dylib] Error 1
make: *** [zlib] Error 2
It was suggested that adding the following flag would fix the issue:
export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
but it has not.
my project blows up with this message:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I cannot figure out what I am doing wrong. I've taken out all of the offending code (i think), and I've even deleted everything back to the original classes, but I still get the messages.
Any suggestions?
Thanks.
here's the entire log:
Ld /Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Products/Debug-iphonesimulator/NewTest.app/NewTest normal i386
cd "/Users/xxxx/Desktop/NewTest copy"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Products/Debug-iphonesimulator -F/Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Products/Debug-iphonesimulator -filelist /Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Intermediates/NewTest.build/Debug-iphonesimulator/NewTest.build/Objects-normal/i386/NewTest.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Products/Debug-iphonesimulator/NewTest.app/NewTest
ld: duplicate symbol _OBJC_IVAR_$_ViewController.testprop3 in /Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Intermediates/NewTest.build/Debug-iphonesimulator/NewTest.build/Objects-normal/i386/OtherClass.o and /Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Intermediates/NewTest.build/Debug-iphonesimulator/NewTest.build/Objects-normal/i386/ViewController.o for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Duplicate symbol _OBJC_IVAR_$_ViewController.testprop3 in /Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Intermediates/NewTest.build/Debug-iphonesimulator/NewTest.build/Objects-normal/i386/OtherClass.o and /Users/xxxx/Library/Developer/Xcode/DerivedData/NewTest-gwytsbxrryxjejdbvifxuyomdpug/Build/Intermediates/NewTest.build/Debug-iphonesimulator/NewTest.build/Objects-normal/i386/ViewController.o for architecture i386
It appears that you have double defined testprop3.