I have written c++ functions that use dlib face recognition. On Mac my code works fine but I cannot compile it to iOS.
First I generated Xcode projects with
cmake -G Xcode ..
When I try to build the library through Xcode project, the linker
Ld xcodebuild/Debug-iphoneos/dlibwrapper.bundle/dlibwrapper normal arm64
cd /Users/MKoi/dlib-19.7/examples
export IPHONEOS_DEPLOYMENT_TARGET=11.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.1.sdk -L/Users/MKoi/dlib-19.7/examples/xcodebuild/Debug-iphoneos -F/Users/MKoi/dlib-19.7/examples/xcodebuild/Debug-iphoneos -F/Library/Frameworks -filelist /Users/MKoi/dlib-19.7/examples/xcodebuild/examples.build/Debug-iphoneos/dlibwrapper.build/Objects-normal/arm64/dlibwrapper.LinkFileList -miphoneos-version-min=11.1 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/MKoi/dlib-19.7/examples/xcodebuild/examples.build/Debug-iphoneos/dlibwrapper.build/Objects-normal/arm64/dlibwrapper_lto.o -Xlinker -no_deduplicate -bundle -Wl,-headerpad_max_install_names /Users/MKoi/dlib-19.7/examples/xcodebuild/dlib_build/Debug-iphoneos/libdlib.a /usr/lib/libcblas.dylib /usr/lib/liblapack.dylib /usr/lib/libsqlite3.dylib -Xlinker -dependency_info -Xlinker /Users/MKoi/dlib-19.7/examples/xcodebuild/examples.build/Debug-iphoneos/dlibwrapper.build/Objects-normal/arm64/dlibwrapper_dependency_info.dat -o /Users/MKoi/dlib-19.7/examples/xcodebuild/Debug-iphoneos/dlibwrapper.bundle/dlibwrapper
fails with:
ld: warning: ignoring file /usr/lib/libcblas.dylib, missing required architecture arm64 in file /usr/lib/libcblas.dylib (3 slices)
ld: warning: ignoring file /usr/lib/liblapack.dylib, missing required architecture arm64 in file /usr/lib/liblapack.dylib (3 slices)
....
Undefined symbols for architecture arm64:
....
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How could I include arm64 versions of libcblas.dylib and liblapack.dylib to the build? Did I miss some build step?
Related
I am trying to follow this guide here for building SDL2 for iOS:
http://lazyfoo.net/tutorials/SDL/52_hello_mobile/ios_mac/index.php
I am able to build the libSDL2.a static library, however I am getting a linker error when I attempt to build his example hello world application which uses it.
Ld /Users/testuser/Library/Developer/Xcode/DerivedData/___PROJECTNAME___-egvszvnfjpicgqdtaazpczjuebut/Build/Products/Debug-iphonesimulator/___PROJECTNAME___.app/___PROJECTNAME___ normal x86_64
cd "/Users/testuser/Documents/iosBuild/SDL iOS Application"
export IPHONEOS_DEPLOYMENT_TARGET=10.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -L/Users/testuser/Library/Developer/Xcode/DerivedData/___PROJECTNAME___-egvszvnfjpicgqdtaazpczjuebut/Build/Products/Debug-iphonesimulator -F/Users/testuser/Library/Developer/Xcode/DerivedData/___PROJECTNAME___-egvszvnfjpicgqdtaazpczjuebut/Build/Products/Debug-iphonesimulator -filelist /Users/testuser/Library/Developer/Xcode/DerivedData/___PROJECTNAME___-egvszvnfjpicgqdtaazpczjuebut/Build/Intermediates/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/Objects-normal/x86_64/___PROJECTNAME___.LinkFileList -mios-simulator-version-min=10.0 -Xlinker -object_path_lto -Xlinker /Users/testuser/Library/Developer/Xcode/DerivedData/___PROJECTNAME___-egvszvnfjpicgqdtaazpczjuebut/Build/Intermediates/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/Objects-normal/x86_64/___PROJECTNAME____lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -lSDL2 -framework GameController -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework CoreAudio -framework AudioToolbox -framework CoreGraphics -framework CoreMotion -Xlinker -dependency_info -Xlinker /Users/testuser/Library/Developer/Xcode/DerivedData/___PROJECTNAME___-egvszvnfjpicgqdtaazpczjuebut/Build/Intermediates/___PROJECTNAME___.build/Debug-iphonesimulator/___PROJECTNAME___.build/Objects-normal/x86_64/___PROJECTNAME____dependency_info.dat -o /Users/testuser/Library/Developer/Xcode/DerivedData/___PROJECTNAME___-egvszvnfjpicgqdtaazpczjuebut/Build/Products/Debug-iphonesimulator/___PROJECTNAME___.app/___PROJECTNAME___
ld: library not found for -lSDL2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Per his instructions, I copied the project template and added the libSDL2.a lib that I built under the Build Phases -> link binary with libraries menu:
Any suggestions for how I can debug this problem?
Edit: My build target configuration in the project which uses the library:
try to build your library with this script. the final product will be placed in your home ~/SDL directory.
#!/bin/sh
PREFIX=$HOME/SDL
SYMROOT="SYMROOT=$PREFIX/release"
SDK_DEVICE="-sdk iphoneos"
SDK_SIMULATOR="-sdk iphonesimulator"
CONF_DEBUG="-configuration Debug"
CONF_RELEASE="-configuration Release"
mkdir -p $PREFIX
cd $PREFIX
wget https://www.libsdl.org/release/SDL2-2.0.4.zip
unzip SDL2-2.0.4.zip
rm -f SDL2-2.0.4.zip
# ------------------------------------------------------------------------
# SDL
# ------------------------------------------------------------------------
cd $PREFIX/SDL2-2.0.4/Xcode-iOS/SDL
SCHEME="libSDL"
PROJ="-project SDL.xcodeproj"
#xcodebuild OTHER_CFLAGS="-fembed-bitcode" OTHER_LDFLAGS="-lobjc" ONLY_ACTIVE_ARCH=NO -arch i386 -arch x86_64 $PROJ $SDK_SIMULATOR $CONF_DEBUG -scheme='$SCHEME' build $SYMROOT
xcodebuild OTHER_CFLAGS="-fembed-bitcode" ONLY_ACTIVE_ARCH=NO -arch i386 -arch x86_64 $PROJ $SDK_SIMULATOR $CONF_RELEASE -scheme='$SCHEME' build $SYMROOT
#xcodebuild OTHER_CFLAGS="-fembed-bitcode" OTHER_LDFLAGS="-lobjc" ONLY_ACTIVE_ARCH=NO -arch arm64 -arch armv7 $PROJ $SDK_DEVICE $CONF_DEBUG -scheme='$SCHEME' build $SYMROOT
xcodebuild OTHER_CFLAGS="-fembed-bitcode" ONLY_ACTIVE_ARCH=NO -arch arm64 -arch armv7 $PROJ $SDK_DEVICE $CONF_RELEASE -scheme='$SCHEME' build $SYMROOT
lipo $PREFIX/release/Release-iphonesimulator/libSDL2.a $PREFIX/release/Release-iphoneos/libSDL2.a -create -output $PREFIX/libSDL2.a
It's likely that the static library you built does not contain the architecture for which you're building your application. You'll need to build a static library that contains the architectures for the platform you want to build.
Also, keep in mind that it's not actually supported to put architectures for different platforms (such as iOS and tvOS, or even iOS and iOS Simulator—the simulators are separate platforms) in a single binary. You'll need a separate library or framework for each platform you're targeting, though each one can of course contain slices for all of that platform's supported architectures.
When I try to build my Xcode project this error comes up:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It is really frustrating because I cannot get rid of it. It shows up in my normal target and my test target. Please help.
The full error is below thanks.
Ld /Users/callumbondy/Library/Developer/Xcode/DerivedData/Dotcha!-ajrirvxbqfcklkfaxgrfgwslckom/Build/Products/Debug-iphonesimulator/Dotcha!.app/Dotcha! normal i386
cd "/Users/callumbondy/Desktop/Desktop/Projects/Dotcha!"
export IPHONEOS_DEPLOYMENT_TARGET=8.2
export 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/iPhoneSimulator8.3.sdk -L/Users/callumbondy/Library/Developer/Xcode/DerivedData/Dotcha!-ajrirvxbqfcklkfaxgrfgwslckom/Build/Products/Debug-iphonesimulator -L/Applications/Adobe\ Flash\ CC\ 2014/AIR13.0/lib/aot/stub -F/Users/callumbondy/Library/Developer/Xcode/DerivedData/Dotcha!-ajrirvxbqfcklkfaxgrfgwslckom/Build/Products/Debug-iphonesimulator -filelist /Users/callumbondy/Library/Developer/Xcode/DerivedData/Dotcha!-ajrirvxbqfcklkfaxgrfgwslckom/Build/Intermediates/Dotcha!.build/Debug-iphonesimulator/Dotcha!.build/Objects-normal/i386/Dotcha!.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/callumbondy/Library/Developer/Xcode/DerivedData/Dotcha!-ajrirvxbqfcklkfaxgrfgwslckom/Build/Intermediates/Dotcha!.build/Debug-iphonesimulator/Dotcha!.build/Objects-normal/i386/Dotcha_.swiftmodule -mios-simulator-version-min=8.2 -framework StoreKit -framework iAd -framework GameKit -Xlinker -dependency_info -Xlinker /Users/callumbondy/Library/Developer/Xcode/DerivedData/Dotcha!-ajrirvxbqfcklkfaxgrfgwslckom/Build/Intermediates/Dotcha!.build/Debug-iphonesimulator/Dotcha!.build/Objects-normal/i386/Dotcha!_dependency_info.dat -o /Users/callumbondy/Library/Developer/Xcode/DerivedData/Dotcha!-ajrirvxbqfcklkfaxgrfgwslckom/Build/Products/Debug-iphonesimulator/Dotcha!.app/Dotcha!
ld: warning: ignoring file /Applications/Adobe Flash CC 2014/AIR13.0/lib/aot/stub/libSystem.dylib, file was built for armv7 which is not the architecture being linked (i386): /Applications/Adobe Flash CC 2014/AIR13.0/lib/aot/stub/libSystem.dylib
ld: in '/Applications/Adobe Flash CC 2014/AIR13.0/lib/aot/stub/libobjc.A.dylib', file was built for armv7 which is not the architecture being linked (i386): /Applications/Adobe Flash CC 2014/AIR13.0/lib/aot/stub/libobjc.A.dylib for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The library libobjc.A.dylib that you are using don't have an i386 architecture slice. You probably is getting this error when running the app on simulator right?
Compile using a compatible version of your library or try to run on a real device to see if it resolves your problem.
I am trying to implement openssl code I found into my project but I get these linker errors that aren't going away. I checked that the frameworks are properly linked and even included the library and header search paths manually using ../lib and ../include. Despite this the error goes away when I get rid of the Openssl function or any function calls such as EVP_OpenUpdate or EVP_OpenInit. This only if I create and then call the function from my ViewController.h file for some reason.
Here is the log of the error:
Ld /Users/User/Library/Developer/Xcode/DerivedData/LineaSSL-clrggexngizkqqbtcxpnmsciuwag/Build/Products/Debug-iphoneos/LineaSSL.app/LineaSSL normal armv7
cd /Users/User/Documents/LineaSSL
setenv IPHONEOS_DEPLOYMENT_TARGET 4.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
/iPhoneOS5.1.sdk -L/Users/User/Library/Developer/Xcode/DerivedData/LineaSSL-clrggexngizkqqbtcxpnmsciuwag/Build/Products/Debug-iphoneos -L/Users/User/Documents/LineaSSL/../../Desktop/x2on-OpenSSL-for-iPhone-a095890/OpenSSL-for-iOS/lib -L/Users/User/Documents/LineaSSL/../../Downloads/DTDevices-iOS_2012-06-15_v1/Library -L/Users/User/Documents/LineaSSL/OpenSSL-for-iOS/lib -L/Users/User/Documents/LineaSSL/lib -F/Users/User/Library/Developer/Xcode/DerivedData/LineaSSL-clrggexngizkqqbtcxpnmsciuwag/Build/Products/Debug-iphoneos -Finclude -Finclude/openssl -filelist /Users/User/Library/Developer/Xcode/DerivedData/LineaSSL-clrggexngizkqqbtcxpnmsciuwag/Build/Intermediates/LineaSSL.build/Debug-iphoneos/LineaSSL.build/Objects-normal/armv7/LineaSSL.LinkFileList -dead_strip -miphoneos-version-min=4.0 -lcrypto -lssl -framework CoreGraphics -framework ExternalAccessory -framework Foundation -framework UIKit -ldtdev -o /Users/User/Library/Developer/Xcode/DerivedData/LineaSSL-clrggexngizkqqbtcxpnmsciuwag/Build/Products/Debug-iphoneos/LineaSSL.app/LineaSSL
ld: warning: ignoring file /Users/User/Desktop/x2on-OpenSSL-for-iPhone-a095890/OpenSSL-for-iOS/lib/libcrypto.a, file was built for archive which is not the architecture being linked (armv7)
ld: warning: ignoring file /Users/User/Desktop/x2on-OpenSSL-for-iPhone-a095890/OpenSSL-for-iOS/lib/libssl.a, file was built for archive which is not the architecture being linked (armv7)
Undefined symbols for architecture armv7:
"_rsa_open3", referenced from:
-[ViewController barcodeData:isotype:] in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please let me know what I should do in regards to this error.
Thanks in advance.
I had to rebuild the entire project from scratch in order to get it to work. I don't know why I had to do such a thing though.
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.
I know that this question had been asked many times, but every answer seems different. I have built my project and tried to run it, but I get this error:
Ld "/Users/******/Library/Developer/Xcode/DerivedData/Cypher_Bot-dxylepzskcnrtybprtuaotmycjjo/Build/Products/Debug-iphonesimulator/Cypher Bot.app/Cypher Bot" normal i386
cd "/Users/******/Xcode/iOS/Cypher Bot/Universal/Cypher Bot/Cypher Bot"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/********/Library/Developer/Xcode/DerivedData/Cypher_Bot-dxylepzskcnrtybprtuaotmycjjo/Build/Products/Debug-iphonesimulator -F/Users/**********/Library/Developer/Xcode/DerivedData/Cypher_Bot-dxylepzskcnrtybprtuaotmycjjo/Build/Products/Debug-iphonesimulator -filelist "/Users/*******/Library/Developer/Xcode/DerivedData/Cypher_Bot-dxylepzskcnrtybprtuaotmycjjo/Build/Intermediates/Cypher Bot.build/Debug-iphonesimulator/Cypher Bot.build/Objects-normal/i386/Cypher Bot.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework Security -framework UIKit -framework Foundation -framework CoreGraphics -framework CoreData -o "/Users/********/Library/Developer/Xcode/DerivedData/Cypher_Bot-dxylepzskcnrtybprtuaotmycjjo/Build/Products/Debug-iphonesimulator/Cypher Bot.app/Cypher Bot"
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MFMailComposeViewController", referenced from:
objc-class-ref in CryptoMainViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I also get this right below the message above:
What does this mean? What do I do to fix it?
The error means that the linker can't find the class definition for MFMailComposeViewController. That class is defined in the MessageUI framework. Did you add the MessageUI framework to your target? If you don't know how to do that, read this: How to "add existing frameworks" in Xcode 4?