I am creating native library binding for the Wikitude SDK.
The MonoTouch app fails linking:
Undefined symbols for architecture armv7:
"std::__1::basic_string, std::__1::allocator >::find_last_of(char const*, unsigned long, unsigned long) const", referenced from:
WtUnzip::unzipFileTo(char const*, bool)in WikitudeSDK.a(wtunzip.o)
...
My LinkWith:
[assembly: LinkWith ("WikitudeSDK.a", LinkTarget.ArmV7, Frameworks = "CoreVideo Security SystemConfiguration CoreMedia AVFoundation CFNetwork CoreLocation CoreMotion MediaPlayer OpenGLES QuartzCore CoreGraphics", ForceLoad = true, LinkerFlags = "-lsqlite3.0 -ObjC", IsCxx = true)]
I have to admit that I am new to this MonoTouch/IOS world, by I am trying to get my head out of the water.
What should I do to get my app to link?
I just figured that I needed to add libc++ in my LinkWith. My new LinkWith looks like this:
[assembly: LinkWith ("WikitudeSDK.a", LinkTarget.ArmV7, Frameworks = "CoreVideo Security SystemConfiguration CoreMedia AVFoundation CFNetwork CoreLocation CoreMotion MediaPlayer OpenGLES QuartzCore CoreGraphics", ForceLoad = true, LinkerFlags = "-lsqlite3.0 -ObjC -lc++", IsCxx = true)]
Hopefully that can eventually help others.
I was dealing with an issue where the linking step was failing with "Native linking failed, undefined symbol: std::string::find_last_of(char const*, unsigned long, unsigned long)..."
It turned out the iOS Deployment Target for the app was apparently not matched with the original native library. By matching those up (by comparing against a working "consumer" of the same binding library) I was able to get past the errors.
Related
The Issue
I'm trying to compile an iOS test project with the NDI v3.0 SDK and I'm running into Apple Mach-O Linker (ld) Errors.
It's a static framework (libndi_ios.a) that you are to link your binary to, and reference the headers in order to use their C/C++ API in our ObjC++ code.
I am copying sample code of theirs that simply creates a NDIlib_send_instance_t for use. As soon as I attempt to compile this code the build fails with this linker error:
Undefined symbols for architecture armv7:
"NDI_multicast::send::packetize::~packetize()", referenced from:
std::__1::__shared_ptr_emplace<NDI_multicast::send::packetize, std::__1::allocator<NDI_multicast::send::packetize> >::~__shared_ptr_emplace() in libndi_ios.a(send_server.o)
std::__1::__shared_ptr_emplace<NDI_multicast::send::packetize, std::__1::allocator<NDI_multicast::send::packetize> >::~__shared_ptr_emplace() in libndi_ios.a(send_server.o)
std::__1::__shared_ptr_emplace<NDI_multicast::send::packetize, std::__1::allocator<NDI_multicast::send::packetize> >::__on_zero_shared() in libndi_ios.a(send_server.o)
NDI_multicast::send::send(NDI_multicast::send::config_multicast_t const&) in libndi_ios.a(NDI_multicast_send.o)
NDI_multicast::send::send(NDI_multicast::send::config_unicast_t const&) in libndi_ios.a(NDI_multicast_send.o)
NDI_multicast::send::~send() in libndi_ios.a(NDI_multicast_send.o)
"NDI_multicast::send::packetize::packetize()", referenced from:
ndi::reference::send::server::send(ndi::reference::buffer_pack const&, ndi::reference::send::connection*) in libndi_ios.a(send_server.o)
NDI_multicast::send::send(NDI_multicast::send::config_multicast_t const&) in libndi_ios.a(NDI_multicast_send.o)
NDI_multicast::send::send(NDI_multicast::send::config_unicast_t const&) in libndi_ios.a(NDI_multicast_send.o)
"NDI_multicast::send::packetize::operator()(std::__1::function<std::__1::pair<unsigned char const*, unsigned long> (unsigned long, unsigned long)>)", referenced from:
ndi::reference::send::server::send(ndi::reference::buffer_pack const&, ndi::reference::send::connection*) in libndi_ios.a(send_server.o)
NDI_multicast::send::operator()(NDI_multicast::send::buffer_source_t&, std::__1::pair<int, int>, std::__1::function<void (bool)>) in libndi_ios.a(NDI_multicast_send.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Reproducing
You can reproduce this error by following the steps below. I'm currently using Xcode 9.4 (and I've tested on the latest beta with the same results)
The steps I have taken to get this error:
Install the NewTek NDI SDK from their website here
Create a new Xcode project for a single view Objective-C iOS app
Rename the ViewController.m to ViewController.mm (So it's compiled as Objc++)
Add /NewTek NDI SDK/include to Header Search Paths
Add /NewTek NDI SDK/lib/iOS to Library Search Paths
Add the libndi_ios.a under the "Link Binary With Libraries" in "Build Phases".
Add this code to the ViewController.mm:
NDIlib_initialize();
NDIlib_send_create_t NDI_send_create_desc;
NDI_send_create_desc.p_ndi_name = "My Audio";
NDI_send_create_desc.clock_audio = true;
// (Without this line, everything compiles fine...)
NDIlib_send_instance_t pNDI_send = NDIlib_send_create(&NDI_send_create_desc);
This will fail with the error above.
One thing that I found interesting was that using other code from their samples, such as for receiving video, worked as expected. The issue only exists when using the NDIlib_send_create API.
Does anyone have any tips, or ideas to lend?
You can find the NewTek iOS SDK by requesting it on their website here.
use nariakiiwatani's ofxNDI static library version.
https://github.com/nariakiiwatani/ofxNDI/blob/master/libs/NDI/lib/iOS/libndi_ios.a
I solved same problem by his static library version.
After contacting support at NewTek about this issue, and linking to this post, they have updated (or are in the process of updating) the library that is included in the SDK. I believe that it will be posted on their website shortly.
Thanks to both Lightlive.dev and emrahgunduz for your suggestions 🙌
I have been trying to find the problem for hours with no result.
I have updated to Xcode 6 and get this error on both ioS8.0 & 7.1 since then :
Undefined symbols for architecture armv7:
"___gnu_f2h_ieee", referenced from:
_playbackCallback in Audio.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks for your help.
EDIT (full build log error) :
Ld /Users/rjc/Library/Developer/Xcode/DerivedData/Acc-hjhfomxkmwbyxwbfzjbduabbhlcc/Build/Products/Debug-iphoneos/Acc.app/Acc normal armv7
cd /Users/rjc/Desktop/apps/Acc
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode6-Beta2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode6-Beta2.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode6-Beta2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk -L/Users/rjc/Library/Developer/Xcode/DerivedData/Acc-hjhfomxkmwbyxwbfzjbduabbhlcc/Build/Products/Debug-iphoneos -L/Users/rjc/Desktop/apps/Acc/Acc -F/Users/rjc/Library/Developer/Xcode/DerivedData/Acc-hjhfomxkmwbyxwbfzjbduabbhlcc/Build/Products/Debug-iphoneos -F/Users/rjc/Desktop/apps/Acc -filelist /Users/rjc/Library/Developer/Xcode/DerivedData/Acc-hjhfomxkmwbyxwbfzjbduabbhlcc/Build/Intermediates/Acc.build/Debug-iphoneos/Acc.build/Objects-normal/armv7/Acc.LinkFileList -dead_strip -ObjC -all_load -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=7.1 -lCorePlot-CocoaTouch -framework CoreTelephony -framework MediaPlayer -framework MessageUI -framework Social -framework Accelerate -framework CoreLocation -framework MobileCoreServices -framework AVFoundation -framework AudioToolbox -framework CoreAudio -framework QuartzCore -framework UIKit -framework Foundation -framework CoreGraphics -framework CoreData -Xlinker -dependency_info -Xlinker /Users/rjc/Library/Developer/Xcode/DerivedData/Acc-hjhfomxkmwbyxwbfzjbduabbhlcc/Build/Intermediates/Acc.build/Debug-iphoneos/Acc.build/Objects-normal/armv7/Acc_dependency_info.dat -o /Users/rjc/Library/Developer/Xcode/DerivedData/Acc-hjhfomxkmwbyxwbfzjbduabbhlcc/Build/Products/Debug-iphoneos/Acc.app/Acc
I also faced a very similar issue and found this. It was resolved the issue and was very helpful.
http://helpdesk.metaio.com/questions/35905/undefined-symbols-for-architecture-i386-xcode-6-ios-8-beta-6/36538
Make a .c file (name is not a concern, in my case i made i386Symbols.c) and add it to the project. Then paste this.
// i386Symbols.c
// Your project
//
// Created by Ludwig on 10/2/14.
// Copyright (c) 2014. All rights reserved.
//
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
FILE *fopen$UNIX2003( const char *filename, const char *mode )
{
return fopen(filename, mode);
}
int fputs$UNIX2003(const char *res1, FILE *res2){
return fputs(res1,res2);
}
int nanosleep$UNIX2003(int val){
return usleep(val);
}
char* strerror$UNIX2003(int errornum){
return strerror(errornum);
}
double strtod$UNIX2003(const char *nptr, char **endptr){
return strtod(nptr, endptr);
}
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
return fwrite(a, b, c, d);
}
I couldn't resolve the issue, but I have a partial workaround.
It seems that there is no armv7 slice for many floating point functions. I assume that they will be included in a later release (or in the final release) of Xcode 6.
The armv7s slice is present instead: since I was debugging on an iPhone5, that uses this latter instruction set, I had just to remove the architecture from the build settings.
Go on your project settings, select your project.
Under Build Settings, look for the Architectures entry.
Edit it, remove $(ARCHS_STANDARD) and replace it with armv7s.
As jcr noted, you may have to switch the Active Architecture Only option from YES to NO.
This will allow to build and run. Unfortunately I have no arm64 device to test, but it might be possible that this slice is also included.
The monotouch binding that I created for the Wikitude SDK framework does not work at run time. I created my binding by following these instructions: https://stackoverflow.com/a/13070064/42826.
When I try to instantiate my wrapper class at run-time, I get the following exception:
Wrapper type 'Wikitude.WTArchitectView' is missing its native
ObjectiveC class 'WTArchitectView'.
It looks like the native class WTArchitectView goes not get loaded by the binding assembly at run-time. The native library WikitudeSDK.a is indeed located in the binding assembly with the ObjcBindingNativeLibrary build action.
Here is my LinkWith declaration (notice the -ObjC that is required by the Wikitude native library):
[assembly: LinkWith ("WikitudeSDK.a", LinkTarget.ArmV7 | LinkTarget.Simulator, Frameworks = "CoreVideo Security SystemConfiguration CoreMedia AVFoundation CFNetwork CoreLocation CoreMotion MediaPlayer OpenGLES QuartzCore CoreGraphics", ForceLoad = true, LinkerFlags = "-ObjC", IsCxx = true)]
Most of my ApiDefinition.cs was created using Objective Sharpie.
Note: I only left a single function for testing purposes.
namespace Wikitude
{
[BaseType (typeof (UIView))]
interface WTArchitectView {
[Export ("initializeWithKey:motionManager:")]
void InitializeWithKey (string key, NSObject motionManager);
}
}
Here is the Wikitude SDK header file: http://pastebin.com/HKBED11u
My project has the ARMv7 + ARMv7s supported architectures.
Do I have to force loading the native library somehow or did I simply miss something obvious to get the wrapper to work?
The LinkWith attribute only mention ArmV7 and Simulator as LinkTargets. If your device is Armv7s, this could explain why it doesn't work.
I am getting this error which I try to add my OpenCV based library to a MonoTouch project:
Undefined symbols for architecture i386:
"cv::isContourConvex(cv::_InputArray const&)", referenced from:
aruco::MarkerDetector::detectRectangles(cv::Mat const&, std::vector<aruco::MarkerDetector::MarkerCandidate, std::allocator<aruco::MarkerDetector::MarkerCandidate> >&)in libAruco.a(markerdetector.o)
"cv::warpPerspective(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Size_<int>, int, int, cv::Scalar_<double> const&)", referenced from:
aruco::MarkerDetector::warp_cylinder(cv::Mat&, cv::Mat&, cv::Size_<int>, aruco::MarkerDetector::MarkerCandidate&)in libAruco.a(markerdetector.o)
aruco::MarkerDetector::warp(cv::Mat&, cv::Mat&, cv::Size_<int>, std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >)in libAruco.a(markerdetector.o)
"cv::FileNodeIterator::readRaw(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*, unsigned long)", referenced from:
cv::VecReaderProxy<float, 1>::operator()(std::vector<float, std::allocator<float> >&, unsigned long) constin libAruco.a(board.o)
"cv::FileNodeIterator::FileNodeIterator(CvFileStorage const*, CvFileNode const*, unsigned long)", referenced from:
cv::FileNode::begin() constin libAruco.a(board.o)
cv::FileNode::end() constin libAruco.a(board.o)
This is only a sample of the full list of opencv methods which are having this problem, as it is easily over 100.
I'm attempting to run this in the simulator (I only have the trial edition of monotouch). I'm compiling for the ipad simulator in xcode and have followed the Opencv tutorial as far as setting up my project with the pre-built framework from their website. I was maybe wondering if there is some linker flag I need to enter as my static library is not as large as I would expect it to be given the fact it needs to link with several of the opencv modules (that's just a gut feeling and not necessarily indicative of anything).
I suppose its also important to mention that I have very little experience with iOS and MonoTouch development, so I could have missed something really simple.
Your static library might not be a FAT (multiple architectures) library or may not include i386 code.
The easy way to find out is to try, from a terminal window:
lipo -info libAruco.a
That should return something like:
Architectures in the fat file: libAruco.a are: i386 ...
where ... is likely armv7 (or more) to support the iOS devices.
OTOH if i386 is missing then it means your library is not compiled to work on the simulator. In such case you'll need to return to Xcode to build this architecture and use lipo to create a FAT library (that includes both the arm and i386 architectures).
I got some issues as below while try to build Pocket-OCR
Undefined symbols for architecture i386:
"tesseract::TessBaseAPI::SetVariable(char const*, char const*)",
referenced from:
-[OCRDisplayViewController viewDidLoad] in OCRDisplayViewController.o
"tesseract::TessBaseAPI::TesseractRect(unsigned char const*, int, int,
int, int, int, int)", referenced from:
-[OCRDisplayViewController readAndProcessImage:] in OCRDisplayViewController.o
-[OCRDisplayViewController threadedReadAndProcessImage:] in OCRDisplayViewController.o
"tesseract::TessBaseAPI::AllWordConfidences()", referenced from:
-[OCRDisplayViewController viewDidLoad] in OCRDisplayViewController.o "tesseract::TessBaseAPI::End()",
referenced from:
-[OCRDisplayViewController dealloc] in OCRDisplayViewController.o "tesseract::TessBaseAPI::Init(char
const*, char const*, tesseract::OcrEngineMode, char*, int,
GenericVector const, GenericVector const*, bool)",
referenced from:
tesseract::TessBaseAPI::Init(char const*, char const*) in OCRDisplayViewController.o "tesseract::TessBaseAPI::TessBaseAPI()",
referenced from:
-[OCRDisplayViewController viewDidLoad] in OCRDisplayViewController.o ld: symbol(s) not found for architecture
i386 clang: error: linker command failed with exit code 1 (use -v to
see invocation)
What should I do to resolve this issues?
I search on goole for answer but does'n get much help to solve the issues.
you can reference this solution on SO
I got the solution for this and also got new links and examples that are working fine and have completed my demo project
May these links are useful for others who want's to use it.
Example One
Now got the exact link from where I am able to develop my demo project.
Example Which I used
Though the answer is already accepted I found the solution that worked for me:
Apparently xCode does not add frameworks automatically to the "Link Binary With Libraries"- and "Copy Bundle Resources"-lists.
You can find them by clicking on your projectname (blue icon) and then go to "Build Phases" and add them to both lists. Then change from "Required" to "Optional". Both can be seen in the screenshot.