Creating iOS Static Library with multiple libraries - ios

I'm currently trying to create my own iOS static library, which in turn relies on several static libraries. The overall architecture looks like this:
PersonalSDK
libjpeg.a
opencv2.framework
The PersonalSDK project compiles just fine, and I am able to add PersonalSDK into a sample app (PersonalApp). However, when trying to build PersonalApp, I am getting a whole rash of undefined symbol errors such as:
"cv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)", referenced from:
Segmenter::segmentize(cv::Rect_<int>&, cv::Mat&, cv::Mat&, cv::Size_<float>&, bool, bool) in personalSDK.a(Segmenter.o)
"cv::findContours(cv::_OutputArray const&, cv::_OutputArray const&, int, int, cv::Point_<int>)", referenced from:
Segmenter::segmentize(cv::Rect_<int>&, cv::Mat&, cv::Mat&, cv::Size_<float>&, bool, bool) in personalSDK.a(Segmenter.o)
Does anyone know how I should go about doing this correctly?

After much trying, I have given up on using static libraries and have gone with using a framework instead!

Related

Xcode 10 Removing lstdc++

lstdc++ is removed from Xcode 10 so I removed this lib from "Link Binary With Libraries" and I added libc++.tbd but I got something like that in linker
Undefined symbols for architecture x86_64:
"std::ios_base::Init::~Init()", referenced from:
__GLOBAL__sub_I_BVMDOfflineMapMerge.cpp in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::string::assign(std::string const&)", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::string::_Rep::_S_empty_rep_storage", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)", referenced from:
_baidu_framework::CBVDCVersion::Save() in BaiduMapAPI_Map(BVDEDataCfg.o)
I assue its problem with c++ lib.
maybe ,sdk need update
BaiduMap maybe depend old lib

Google Maps SDK for iOS and libc++

In our project we use library that use libc++ in its implementation very tightly. And when we added Google Maps SDK we got linkage error:
Undefined symbols for architecture i386:
"std::string::_Rep::_M_destroy(std::allocator<char> const&)", referenced from:
gmscore::utils::gmsutils::StringPrintf(char const*, ...) in GoogleMaps(GMSUtils.o)
_GMS_objc_lookUpClass in GoogleMaps(GMSRenames.o)
_GMS_objc_getClass in GoogleMaps(GMSRenames.o)
_GMS_objc_getProtocol in GoogleMaps(GMSRenames.o)
gmscore::vector::CameraPosition::StringValue() const in GoogleMaps(CameraPosition.o)
"std::string::_Rep::_S_empty_rep_storage", referenced from:
gmscore::utils::gmsutils::StringPrintf(char const*, ...) in GoogleMaps(GMSUtils.o)
_GMS_objc_lookUpClass in GoogleMaps(GMSRenames.o)
_GMS_objc_getClass in GoogleMaps(GMSRenames.o)
_GMS_objc_getProtocol in GoogleMaps(GMSRenames.o)
gmscore::vector::CameraPosition::StringValue() const in GoogleMaps(CameraPosition.o)
gmscore::utils::gmsutils::StringPrintf(char const*, ...) in GoogleMaps(GMSUtils.o)
_GMS_objc_lookUpClass in GoogleMaps(GMSRenames.o)
_GMS_objc_getClass in GoogleMaps(GMSRenames.o)
_GMS_objc_getProtocol in GoogleMaps(GMSRenames.o)
gmscore::vector::CameraPosition::StringValue() const in GoogleMaps(CameraPosition.o)
gmscore::utils::gmsutils::StringPrintf(char const*, ...) in GoogleMaps(GMSUtils.o)
_GMS_objc_lookUpClass in GoogleMaps(GMSRenames.o)
_GMS_objc_getClass in GoogleMaps(GMSRenames.o)
_GMS_objc_getProtocol in GoogleMaps(GMSRenames.o)
gmscore::vector::CameraPosition::StringValue() const in GoogleMaps(CameraPosition.o)
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
gmscore::utils::gmsutils::StringPrintf(char const*, ...) in GoogleMaps(GMSUtils.o)
gmscore::model::Point2D::StringValue() const in GoogleMaps(Point2D.o)
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)", referenced from:
gmscore::utils::gmsutils::StringPrintf(char const*, ...) in GoogleMaps(GMSUtils.o)
gmscore::vector::CameraPosition::StringValue() const in GoogleMaps(CameraPosition.o)
It's happened because google maps sdk use libstdc++ library, but we can not change code which use libc++. We tried to encapsulate code and library which use libc++ in static library (*.a), but without success.
Any chance to make things work? Maybe, it's possible to link Google Maps SDK with libc++?
The undefined symbols you are seeing are symbols associated with libstdc++. libstdc++ and libc++ are largely ABI incompatible, even though they present to you (largely) the same API.
In places where the ABI incompatibility is known, such as std::string, libc++ uses a different mangling scheme so that libstdc++ and libc++ strings are not accidentally mixed at run time (which would cause hard-to-debug run time errors).
If you see symbols that have std::__1 in their name, then those are symbols associated libc++, e.g. libc++ has std::__1::basic_string<..., where as libstdc++ has std::basic_string<....
You can use this knowledge of mangling to help you determine which libraries are needing which implementations of the std::lib.
Filing the feature request you did was the very best thing you could do, and thank you for doing that! :-)

Linking OpenCV with MonoTouch returns "Undefined symbols for architecture i386" error

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).

Tesseract 3.01 and Pocket-OCR build issues

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.

I have link error with OpenCV and XCode4.2

I'm trying to link OpenCV in my iPhone project. I upgraded project made on Xcode3.x for latest Xcode. So I need to link opencv built on Xcode 4.3.
I followed the guide in http://niw.at/articles/2009/03/14/using-opencv-on-iphone/en.
But I meet the link error like below.
Undefined symbols for architecture i386:
"_dgesdd_", referenced from:
cv::_SVDcompute(cv::Mat const&, cv::Mat&, cv::Mat*, cv::Mat*, int) in libopencv_core.a(lapack.o)
"_sgesdd_", referenced from:
cv::_SVDcompute(cv::Mat const&, cv::Mat&, cv::Mat*, cv::Mat*, int) in libopencv_core.a(lapack.o)
"_dpotrf_", referenced from:
cv::solve(cv::Mat const&, cv::Mat const&, cv::Mat&, int) in libopencv_core.a(lapack.o)
cv::invert(cv::Mat const&, cv::Mat&, int) in libopencv_core.a(lapack.o)
......
I wonder I never configured i386 architecture. Please tell me how I can fix this issue.
Oh, I found that I missed Accelerate.framework in Build Phase.
You can add framework in [Project]->[Build Phases]->[Link Binary With Libraries].

Resources