I am writing a wrapper that bind to an iOS SDK using the P/Invoke as Sharpie was not able to generate a compilable code for this SDK.
When compiling the iOS App with the wrapper project referenced I am having many linking issues such as this one :
MTOUCH: error MT5210: Native linking failed, undefined symbol: std::locale::classic(). Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
MTOUCH: error MT5210: Native linking failed, undefined symbol: std::__throw_bad_cast(). Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
MTOUCH: error MT5210: Native linking failed, undefined symbol: std::invalid_argument::invalid_argument(std::string const&). Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (Please find the complete log on this complete log file.)
The extra mono touch argument passed from the iOS project are described below:
-cxx -v -gcc_flags "-L${ProjectDir} -lstdc++ -lresolv -liconv -lxml2 -lz -ObjC
-force_load ${ProjectDir}/Libs/libcrypto.a" -cxx -v -gcc_flags "-L${ProjectDir} -lstdc++ -lresolv -liconv -lxml2 -lz -ObjC -force_load ${ProjectDir}/Libs/libssl.a" -cxx -v -gcc_flags "-lstdc++ -lresolv -liconv -lxml2 -lz -ObjC -L${ProjectDir} -framework Security -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework CFNetwork -framework Accelerate -framework AudioToolbox -framework CoreAudio -framework Foundation -framework CoreGraphics -framework UIKit -force_load ${ProjectDir}/Libs/libsipwrapper.a -dead_strip -all_load"
The SDK is composed of three libraries : libcrypto.a, libssl.a and libsipwrapper.a.
Following many articles/posts on the internet, it is recommended to add add the standard library such as -lstdc++, lz, and ObjC, but this not seems to work on my case.
I have also tried to create a Binding Project that includes the three libraries and the wrapper code, the content added to the linkwith files seems like that :
[assembly: LinkWith ("libsipwrapper.a", LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Arm64, Frameworks = "CoreVideo CoreMedia AVFoundation CFNetwork Accelerate AudioToolbox CoreAudio Foundation CoreGraphics UIKit", ForceLoad = false, SmartLink = true, IsCxx = true, LinkerFlags = "-lstdc++ -lresolv -liconv -lxml2 -lz -ObjC")]
The problem was not resolved and I continue to have the described linking errors.
After two days of wasted time, I finally got it, to be clear, it's not evident to guess the parameters to pass to touch, to link correctly a library built by a tier only by yourself. To simplify the task, I have compiled the demo app provided by the SDK provider and used Xcode to compile the demo and gets the parameters sent by Xcode to clang++. this helped me to figure out the parameters to send to monotouch:
--compiler:clang++ -cxx -v -gcc_flags "-stdlib=libstdc++ -L${ProjectDir} -force_load ${ProjectDir}/Libs/libcrypto.a" -cxx -v -gcc_flags "-stdlib=libstdc++ -L${ProjectDir} -force_load ${ProjectDir}/Libs/libssl.a" -cxx -v -gcc_flags "-dead_strip -lresolv -liconv -stdlib=libstdc++ -fobjc-arc -fobjc-link-runtime -framework CoreMedia -framework CoreVideo -framework AVFoundation -framework CFNetwork -framework AudioToolbox -framework CoreAudio -lz -lxml2 -framework CoreGraphics -framework UIKit -framework Foundation -L${ProjectDir} -force_load ${ProjectDir}/Libs/libsipwrapper.a"
Hope this will help other guys.
(Check the two points described by #NyxSway below are also very important)
Without knowing more details of your project, have you checked:
1) have you checked if your .a file really have that symbol it's complaining about using terminal -> grep command, for all the architecture you are supporting: armv7/armv7s/arm64
2) in your C# code, did you use [DllImport ("__Internal")] instead of your own library name?
Related
I'm trying to start a project in XCode 8 using wxWidgets 3.1.0 on OS X 10.11
After downloading wxWidgets-3.1.0 I've built and make everything according to the /docs/osx/install.txt
Now I tried to create a new project and followed their guide: https://wiki.wxwidgets.org/Creating_Xcode_projects_for_wxWidgets_applications
I followed almost every step exactly as instructed. (Static and Debug)
I didn't find the Summary Tab and a Choose Info.plist File Button, I chose it over General under Identity (which may be the same)
Then I tried to compile and run.
I'm getting Warnings and 1 Error.
Warning: Telling me to check dependencies
wxcocoa.xcconfig line 3: Unable to find included file "wx.xcconfig"
Warning: The Copy Bundle Resources build phase contains this target's Info.plist file '/Users/me/Desktop/git/xcode/wx_mac_xcode/Info_cocoa.plist'.
Error:
Ld /Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Products/Debug/Static.app/Contents/MacOS/Static normal x86_64
cd /Users/me/Desktop/git/xcode/wx_mac_xcode
export MACOSX_DEPLOYMENT_TARGET=10.5
/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/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Products/Debug -F/Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Products/Debug -filelist /Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Intermediates/wx_mac_xcode.build/Debug/Static.build/Objects-normal/x86_64/Static.LinkFileList -Xlinker -rpath -Xlinker #executable_path/../Frameworks -mmacosx-version-min=10.5 -Xlinker -no_deduplicate -framework WebKit -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework OpenGL -framework QTKit -framework WebKit -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework OpenGL -framework QTKit -lz -stdlib=libstdc++ -lwx_osx_cocoa_static -Xlinker -dependency_info -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Intermediates/wx_mac_xcode.build/Debug/Static.build/Objects-normal/x86_64/Static_dependency_info.dat -o /Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Products/Debug/Static.app/Contents/MacOS/Static
ld: library not found for -lwx_osx_cocoa_static
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Double checked every step, but don't know how to fix those dependencies.
Project and library are debug mode
Cheers
Ld /Users/simona/Library/Developer/Xcode/DerivedData/HelvetiQuiz-euzcyknolfniushksjdmyofanxpr/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/HelvetiQuiz.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/HelvetiQuiz normal armv7
cd /Users/simona/Desktop/Ios
export IPHONEOS_DEPLOYMENT_TARGET=4.3
export 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/iPhoneOS8.1.sdk -L/Users/simona/Library/Developer/Xcode/DerivedData/HelvetiQuiz-euzcyknolfniushksjdmyofanxpr/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/BuildProductsPath -F/Users/simona/Library/Developer/Xcode/DerivedData/HelvetiQuiz-euzcyknolfniushksjdmyofanxpr/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/BuildProductsPath -filelist /Users/simona/Library/Developer/Xcode/DerivedData/HelvetiQuiz-euzcyknolfniushksjdmyofanxpr/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/HelvetiQuiz.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/HelvetiQuiz.LinkFileList -dead_strip -weak_framework CoreMotion -weak-lSystem -stdlib=libstdc++ -fobjc-link-runtime -miphoneos-version-min=4.3 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework OpenAL -liconv.2 -liPhone-lib -framework AudioToolbox -framework CFNetwork -framework MediaPlayer -framework CoreLocation -framework SystemConfiguration -weak_framework iAd -framework CoreMedia -framework CoreVideo -weak_framework AVFoundation -framework CoreGraphics -weak_framework CoreMotion -weak_framework GameKit -Xlinker -dependency_info -Xlinker /Users/simona/Library/Developer/Xcode/DerivedData/HelvetiQuiz-euzcyknolfniushksjdmyofanxpr/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/HelvetiQuiz.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/HelvetiQuiz_dependency_info.dat -o /Users/simona/Library/Developer/Xcode/DerivedData/HelvetiQuiz-euzcyknolfniushksjdmyofanxpr/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/HelvetiQuiz.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/HelvetiQuiz
ld: library not found for -liPhone-lib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I get this error whenn I try to compile my app. What can I do?
These articles may be of use:
http://answers.unity3d.com/questions/538363/error-when-i-updated-to-xcode-5-to-get-import-to-i.html
http://xyglo.com/blog/2013/11/06/xcode-linker-mystery/
Some quick googling turns up a lot of cases where unity users have had this issue and it is related to the Library Search Path settings (Project -> target -> build settings).
Error Message:
Ld /Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/IntermediateBuildFilesPath/instrument_crate.build/Release-iphoneos/instrument_crate.build/Objects-normal/armv7/instrument_crate normal armv7
cd /Users/xxx/Desktop/instrument_crate/platforms/ios
export IPHONEOS_DEPLOYMENT_TARGET=7.0
export 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/iPhoneOS7.1.sdk -L/Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/BuildProductsPath/Release-iphoneos -F/Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/BuildProductsPath/Release-iphoneos -filelist /Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/IntermediateBuildFilesPath/instrument_crate.build/Release-iphoneos/instrument_crate.build/Objects-normal/armv7/instrument_crate.LinkFileList -dead_strip -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -force_load /Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/InstallationBuildProductsLocation/Applications/libCordova.a -ObjC -fobjc-link-runtime -miphoneos-version-min=7.0 -framework CoreMIDI -framework CoreLocation -framework ImageIO -framework OpenAL -framework AssetsLibrary /Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/BuildProductsPath/Release-iphoneos/libCordova.a -framework Foundation -weak_framework UIKit -framework CoreGraphics -framework AddressBook -framework AddressBookUI -framework AudioToolbox -weak_framework AVFoundation -framework CFNetwork -framework MediaPlayer -framework QuartzCore -framework SystemConfiguration -framework MobileCoreServices -weak_framework CoreMedia -framework CoreLocation -Xlinker -dependency_info -Xlinker /Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/IntermediateBuildFilesPath/instrument_crate.build/Release-iphoneos/instrument_crate.build/Objects-normal/armv7/instrument_crate_dependency_info.dat -o /Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/IntermediateBuildFilesPath/instrument_crate.build/Release-iphoneos/instrument_crate.build/Objects-normal/armv7/instrument_crate
ld: file not found: /Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/InstallationBuildProductsLocation/Applications/libCordova.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(null): File not found: /Users/xxx/Library/Developer/Xcode/DerivedData/instrument_crate-aciaeoafecwxcmgsthlralpykqct/Build/Intermediates/ArchiveIntermediates/instrument_crate/InstallationBuildProductsLocation/Applications/libCordova.a
The SDK I am using requires Mac OS X 10.8, Xcode 5.1, CLI and Cordova 2.9. I use exact those Tools. Would be very nice if anybody would help me.
Go to targets -> Build Phases -> Link Binary with Libraries -> Add libCordova.a library from your project
Clean & build project
Hope it will help to you.
I'm almost done upgrading Cocos2D from 0.99.5 to 2.1, but I don't know how to resolve this error. This is what shows up as the error:
Ld /Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Products/Debug-iphonesimulator/Flying\ Adventure.app/Flying\ Adventure normal i386
cd /Users/Admin/Documents/EriksFiles/Erik/iPad/cocos2d/flyingAdventure/flyingAdventure_current
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
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/iPhoneSimulator7.0.sdk -L/Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Products/Debug-iphonesimulator -F/Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Products/Debug-iphonesimulator -filelist /Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Intermediates/flyingAdventure.build/Debug-iphonesimulator/flyingAdventure1.build/Objects-normal/i386/Flying\ Adventure.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -all_load -ObjC -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -lcocos2d\ libraries -framework CoreText -framework GameKit -lz.1.2.5 -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit -framework AudioToolbox -framework OpenAL -lz -framework AVFoundation -Xlinker -dependency_info -Xlinker /Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Intermediates/flyingAdventure.build/Debug-iphonesimulator/flyingAdventure1.build/Objects-normal/i386/Flying\ Adventure_dependency_info.dat -o /Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Products/Debug-iphonesimulator/Flying\ Adventure.app/Flying\ Adventure
ld: library not found for -lcocos2d libraries
Library not found for -lcocos2d libraries
Linker command failed with exit code 1 (use -v to see invocation)
Does it have to do with my Link Binary With Libraries? Here's what that looks like:
I'm trying to build a x86_64 application on MacOSX, using qmake/qt. I was able to compile in QT4, but not in QT5.
Anyway, after running qmake to generate my makefiles etc:
qmake -recursive -spec macx-clang app.pro CONFIG+='release static'
Then when I run make, eventually I end up here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -arch x86_64 -Wl,-dead_strip -framework Cocoa -framework Carbon -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -o (...author's note--tons of .o files here...) -L../lib -L../../debug -F/Users/seth/workspace/qt5.1.0//5.1.0/clang_64/lib -lprotobuf -framework Security -framework SecurityInterface -framework ApplicationServices -framework CoreFoundation -lxml2 -lbz2 -lxar -framework ScriptingBridge -L/Users/seth/workspace/qt5.1.0//5.1.0/clang_64/plugins/iconengines -lssl -lcrypto -lz -lFLAC -framework Carbon -framework QtWebKitWidgets -framework QtQuick -framework QtQml -framework QtNetwork -framework QtCore -framework QtGui -framework QtOpenGL -framework QtWidgets -framework QtPrintSupport -framework Cocoa -framework QtWebKit -framework QtSql -framework QtSensors -framework QtSvg -framework QtXml -framework OpenGL -framework AGL
ld: '__ZN3Log16DebugE7QStringS3_' in debug/Log.o contains undefined reference for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I do not understand what 'undefined reference for architecture x86_64' means, and that's certainly the heart of the problem. Upon reading some other threads, some suggest that the libraries I'm linking against aren't x86_64, but after checking and rechecking, I can't find any non-x86_64 libraries involved in the process.
All my .o files from the build are Mach-O 64-bit object x86_64, after checking with the file command.
And for all libraries that I'm trying to reference (like libcrypto, for instance):
Non-fat file: ../lib/libcrypto.a is architecture: x86_64
And of course all the mac framework libraries are both 32/64bit capable.
Does anyone have any suggestions on how I could debug this further?
Been fiddling all day, found it.
The method that the link is complaining about has this in it:
qt_mac_execute_apple_script
This method does not exist in qt5.
Also, earlier in the problematic file, I have this:
extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);
if i comment these lines, the error goes away.
So basically, a very bad compiler error for a missing symbol – because the compiler wasn’t nice enough to point out what the actual problem is beyond the vague architecture statement; probably made worse because I’m building my application statically coupled with the extern.