When I add a ".a" file which includes opencv.framework,Xcode encountered such compile errors:
I am pretty sure opencv.framework is there,and I am using opencv 3.1,it should already support arm64. But why does it keep complaining about this? How can I fix it? Thanks a lot.
lipo - info shows following information:
Architectures in the fat file: /Users/Fumin/libVisageWrapper.a are: armv7 i386 x86_64 arm64
You should verify that the library is correctly supporting arm64 using this command:
lipo -info libYourLib.a
The output of this command should show this:
Architectures in the fat file: libYourLib.a are: armv7 arm64
A fat file means a file which holds binary elements for possibly more than one architecture.
If arm64 is missing, you can't build a target for arm64 devices. You might need to ask your supplier of the library to build a fat version which includes the arm64 architecture.
It turns out there is already an opencv library in some other library,so two instance opencvs are conflictting with each other. After .a file provider provide a new version using the same opencv library, now it works fine.
Related
I'm building a framework for tvOS and use an obfuscation software. All sources are compiled with -emit-llvm, obfuscator processes LLVM IR code, then it is compiled into .o with clang++, then ld is being called to produce the final binary and ld fails with this error:
ld: Invalid record for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Program xcrun returned error code 1
Reproducible on different machines with Xcode 11.2.1 and 11.3.
How can I troubleshoot this error? I've added -v to the linker flags but it did not add any hints to the output.
In my case, I was getting this error when the app was linked to external libraries but only when generating the Product Archive.
The solution for me was to disable the bitcode of the Target under Build Settings > Build Options.
I had it previously disabled but my Xcode updated recently and the setting might have gotten overridden.
Answering my own question once again, just in case someone else will hit this issue.
In my case the problem was caused by one of the libraries I was linking to, that was built for arm64e for tvOS. It was a fat binary with arm64, arm64e and x86_64 slices. For some reason ld didn't like it (even though I was building the framework only for arm64) and was throwing out this error. Removing arm64e slice fixed the issue.
Another interesting detail is that Debug build linked fine with that library.
I included an external C++ library for my iOS project. This library was compiled and linked with my project from this: http://github.com/chili-epfl/chilitags/
Then when I run the project on simulator, it compiles. But when I run the project on real device like iPhone7, it fails.
The error was clear:
warning: ignoring file /usr/local/lib/libchilitags.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /usr/local/lib/libchilitags.dylib
Because the lib file was ignored, the functions I used all caused fatal link error.
The reason was clear but I don't know what to do. iPhone7 was arm64 architecture but the file was x86_64 architecture and we have to run it on real devices.
So, what should I do so that I can run x86_64 libs on arm64 real devices? Thanks in advance.
BSo, what should I do so that I can run x86_64 libs on arm64 real devices?
The problem is in different processor instruction set used in x86 and arm64.
So, you should compile the library for arm64 or find it already compiled for target architecture.
I've previously compiled OpenCV 3.0 successfully following this guide, which essentially consists of the following steps:
Download all the prerequisites (XCode, Command Line Tools, CMake and OpenCV source)
Build static libs by configuring CMake (via gui) with:
Uncheck BUILD_SHARED_LIBS
Uncheck BUILD_TESTS
Add an SDK path to CMAKE_OSX_SYSROOT (if it matters, I used /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk).
Add x86_64 to CMAKE_OSX_ARCHITECTURES (emphasis mine, this seems to be the issue, I'm sure I've followed this step)
Uncheck WITH_1394
Uncheck WITH_FFMPEG
Configure and generate via CMake, then make and sudo make install from the CLI.
All of the above alone works fine.
I'm now looking to compile OpenCV with the extra modules. According to their read-me it should be as simple as filling out OPENCV_EXTRA_MODULES_PATH to <opencv_contrib>/modules in CMake and then building as usual.
I followed the steps outlined above with the added parameter and building OpenCV succeeds, however, when trying to use one of the extra modules in a program (namely cv::ximgproc::createStructuredEdgeDetection, if it matters), I'm getting the following error when compiling:
Undefined symbols for architecture x86_64:
"cv::ximgproc::createStructuredEdgeDetection(cv::String const&, cv::Ptr<cv::ximgproc::RFFeatureGetter const>)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've included the header which should include the above:
#include <opencv2/ximgproc.hpp>
I'm compiling via XCode, where I've set an additional header search path of /usr/local/include and a library search path of /usr/local/lib for the project, am I missing something here?
Standard OpenCV functionality works fine.
What could be the issue and how would I go about solving it?
OpenCV contrib modules are built correctly.
You just need to add the contrib libs to your dependencies, in this case adding: -lopencv_ximgproc.
All available libs can be found under <OPENCV_DIR>/install/ folder.
E.g. in my 32bit vc12 static build are in<OPENCV_DIR>/install/x86/vc12/staticlib folder.
I've built a 32 bit library that is a requirement to my project. Here's its lipo info:
LP:lib hcabral$ lipo -info Release-iphoneos/librmservices_iphone.a
input file Release-iphoneos/librmservices_iphone.a is not a fat file
Non-fat file: Release-iphoneos/librmservices_iphone.a is architecture: armv7
I link the library in my project, it shows up in "Link Binary with binaries", etc., and yet I get this error:
Undefined symbols for architecture armv7:
"std::_List_node_base::hook(std::_List_node_base*)", referenced from:
xpath::YaccParser::getObjectPointer(uft::Value*&, bool) in librmservices_iphone.a(xpath_yacc.o)
xpath::YaccParser::performLexicalAnalysis(uft::Value*&) in librmservices_iphone.a(xpath_yacc.o)
"std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:
xpath::Context::removeDynamicContext(uft::Value const&) in librmservices_iphone.a(xpath_context.o)
"_kCFProxyPasswordKey", referenced from:
DLProxySettingsController::getSystemProxySettings() in librmservices_iphone.a(DLProxySettingsController.o)
"_kCFNetworkProxiesHTTPProxy", referenced from:
(...)
All the projects I limited to armv7 and no solution. Any ideas?
So, I have a project A that is pure Objective-C, but it depends on a Project B that is C/C++ and Objective-C, and happens to be 32-bit code only.
Up until Mavericks and Xcode 5.1.1, I built Project B for all platforms (Release and Debug for iOS and i386) in order to debug, run tests and eventually deploy. Project B has its own set of linker flags and options that make it very special.
In project A, I would link the binaries of Project B (libProjectB.a) and it has always worked.
However, during this last iteration, Project A build process complained about missing symbols for armv7, which confused me, because project B is compiled ONLY in armv7 and i386.
The only way I manage to remove 30+ linking errors, was by linking the following frameworks:
libstdc++.6.0.9.dylib
CoreText.framework
CFNetwork.framework
Foundation.framework
I hope these don't look like random frameworks to you, but I found out by adding one by one, based on the type of linking error. For example, I added the CFNetwork only after opening the C++ code and noticing that the symbols would be part of it.
Anyway, again, I don't know why it happened yet, but it happened by using Yosemite and Xcode 6.1. Hope this can shed a light on someone.
I know similar questions has been posted but the solutions I found haven't worked at all for me.
I'm using XCode 4.5 and openCV 2.4.3. I built the library from source, I have the compiler set to LLVM GCC 4.2 and whenever I try to use cvCvtColor(), I get the following error message:
Undefined symbols for architecture x86_64:
"_cvCvtColor referenced from:
_main in main.o
Any insight would be greatly appreciated!
I found the problem and I'm kicking myself. It turns out I didn't import a particular library (libopencv_imgproc to be specific) that cvCvtColor() was on.
In Terminal, "cd" to the directory that contains your OpenCV library (or actually libraries, as I see a few of them are built when I look at this "how to build OpenCV tutorial") and then type in this command:
"nm -arch x86_64 _________.a" (fill in the name of the library where the underscores are)
This dumps out all the symbols of the library. You can egrep or search for "cvCvtColor".
My guess is that you've built OpenCV for 32-bit only (and this will be easy to see if you get absolutely no symbols when specifying "-arch x86_64" in the "nm" command) and that you need to also build your OpenCV libraries for 64-bit (x86_64).