I have 16" M1 Pro MacBook Pro. The third party C library (.a) was built with Intel Mac and there's absolutely no way to modify the code or rebuild with M1 Mac. The binary is x64 binary.
My project is using C++ and Objective-C++ (.mm) with Xcode. It is targeted for Mac app and not iOS. I want to link the C library to my project.
The linked library 'libkfunc64.a' is missing one or more architectures
required by this target: arm64.
I checked similar question but it didn't work:
Can Xcode on m1 Mac build targeting Intel
What I want to do is to generate an Intel binary. I don't need a M1 binary or hybrid binary - I can run Intel binary on Rosetta 2 on M1 Mac.
I created a console-app with "-arch x86_64" option for LLVM C++ compiler and it worked. But I don't know how to pass that option on Xcode.
Please tell me how to do it. I am using Xcode 13.3.
Xcode - Targets - Build Settings
Architectures (x86_64) or Excluded Architectures(arm64).
I've only tested the opposite.
Arm64 required, no x86_64.
I'm having a lot of trouble linking the Intel MKL libraries to my code in C++. I downloaded the MKL library from this link:
https://software.intel.com/content/www/us/en/develop/tools/math-kernel-library/choose-download/windows.html
Then it says to use MKL Link Line Advisor to obtain the proper compiler options, which I'm having a lot of trouble figuring out. For reference, I'm using Windows, g++ 8.1.0 and MinGW-W64. Here is part by part:
Intel product: Intel MKL 2020, since I just downloaded it.
OS: Windows, no issues there.
Compiler: Intel(R) Fortran? I'm using g++ to compile my C++ code, so
I have no idea since that option is not available. Doing some
research in stackoverflow, it seems the right choice is Intel(R)
Fortran
Architecture: Intel(R) 64, since I have a 64-bit OS?
Dynamic/Static Linking: Static linking I guess?
Interface layer: 64-bit, since I have a 64-bit OS?
Threading layer: OpenMP, since my current C++ code uses -fopenmp?
OpenMP library: Intel(R) libiomp5. Only one option, so no issues
here.
Fortran95 Interfaces: BLAS95 and LAPACK95
The above choices give me the following compiler options
/4I8 /module:"%MKLROOT%"\include\intel64/ilp64 -I"%MKLROOT%"\include
And this results in error from the compiler:
/4I8: No such file or directory
Can somebody help me please?
I think you should use -DMKL_ILP64 -I"%MKLROOT%"\include for g++.
You should definitely not pick Intel(R) Fortran for the compiler since you are not compiling Fortran programs.
I am trying to link Intel MKL 11.3 library with Eigen3.2.9 using TDM-GCC-5.1.0 in Win64 environment.
I am using the following definitions:
#define EIGEN_USE_MKL_ALL
-DMKL_LP64
and linking with the ...\lib\intel64_win\*.lib libraries with LP64.
(Note ILP64 gives incompatible integer errors with Eigen)
But I get the following error:
...\mkl\lib\intel64_win\mkl_rt.lib: error adding symbols: File format not recognized
Eigen only supports MKL with LP64 model. MKL supports LP64 and ILP64. Win64 is neither of them. Win64 is LLP64.
https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
According to MKL link line advisor, TDM-GCC is not officially supported on Windows platform.
https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor
The .lib format for VS may not be compatible with cygwin gcc.
I am following a opencv installation document Installation in iOS when compile a ios framework. However, if I did not change platform/ios/build_framework.py and build the framework, I will have the following errors:
build settings from command line:
ARCHS = x86_64
IPHONEOS_DEPLOYMENT_TARGET = 6.0
SDKROOT = iphonesimulator6.1
Build Preparation
Build task concurrency set to 8 via user default IDEBuildOperationMaxNumberOfConcurrentCompileTasks
=== BUILD AGGREGATE TARGET ZERO_CHECK OF PROJECT OpenCV WITH CONFIGURATION Release ===
Check dependencies
=== BUILD NATIVE TARGET zlib OF PROJECT OpenCV WITH CONFIGURATION Release ===
=== BUILD NATIVE TARGET libjpeg OF PROJECT OpenCV WITH CONFIGURATION Release ===
** BUILD FAILED **
Build settings from command line:
ARCHS = x86_64
IPHONEOS_DEPLOYMENT_TARGET = 6.0
SDKROOT = iphonesimulator6.1
=== BUILD NATIVE TARGET zlib OF PROJECT OpenCV WITH CONFIGURATION Release ===
Check dependencies
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).
** BUILD FAILED **
Then, after many tries, I found that if I only compile for architecture armv7, armv7s and i386 by changing the following scripts in platform/ios/build_framework.py the framework can be built successfully.
targets = ["iPhoneOS", "iPhoneOS", "iPhoneSimulator"] #"iPhoneOS", "iPhoneSimulator"
archs = ["armv7", "armv7s", "i386"]#"arm64", , "x86_64"
for i in range(len(targets)):
build_opencv(srcroot, os.path.join(dstroot, "build"), targets[i], archs[i])
Any ideas on how I can compile for the arm64 and x86_64 architecture? Thanks.
Take out the i386 and compile for armv7,armv7s, and arm64 - these are the architecture option for Xcode for 64 bit - iphone5s.
Do not mix intel and arm specification they will not and cannot mix. The architecture command is to inform the compiler on how the object code will be created. Because intel is a CISC processor and arm is a RISC internally their object codes are very different.
a MOVE command for example may generate an x'80'opcode (command instruction) for intel but an x'60'for ARM. far as I know an i386 is the old intel 32 bit architecture, Xcode maybe doing some magic to have universal object codes that can run on both intel and RISC if it is doing so - it will not be efficient, it will always be better to compile to specific architectures.
The 32 bit, 64 bit 128 ..... are addressing modes - they are also the size of the processor registers and determine how much memory (RAM) can be accessed by the CPU. In general, aside from the ability to have huge RAM, higher bit processors will usually reduce the number of instructions to do a particular task.
Because downward compatibility is usually built in, an app compiled for armv6 will typically run in armv7 or even arm64 in compatibility mode but it will not be able to harness the advantages of running a true 64 bit application.
The targets is a higher level specification which specifies which commands can be used for example an iPad has UIPopViewController but this is not supported in an iPhone or an iPod touch.
One last thing - only iPhone 5s works with arm64 if you set another target it will probably flag arm64 as not an option.
So if you are compiling for x86_64 architecture, that is for OS X (laptop or mac tower), NOT iOS (iPad, iPhone).
What are you using? Not Xcode I presume?
You don't need to compile to x86_64 unless you want this to run on a 64-bit mac laptop or desktop... & it doesn't seem like you are trying to do that by your question?
Also, if you have it for i386 it is probably compatible with most OS X machines -- it will just run in 32-bit not 64-bit.
As far as arm64, that is also probably 64-bit. You might not have the libraries for 64-bit? Is your machine running on 64-bit? Check the opencv libraries (dynamic or static?) & see if they are 32 or 64? If they are 32-bit then that is the problem. You'll need to build them as 64-bit libraries or find them as such. I can't give you anymore info without knowing what platform you are on.
I recently learned that OpenCV for iOS has been added to CocoaPods. You can see the podspec here and the Github repository here. With CocoaPods, you create a file named Podfile in the root of your project and paste in this line:
pod 'OpenCV'
Save the file and run pod install from the terminal (assuming that CocoaPods is installed of course).
I have this running on my iPhone 5S, which is 64 bit as well.
I'm under Ubuntu 12.04 x86 64 bit, I have compiled a 32 bit version of llvm/clang from the official svn repository successfully.
I'm now trying to compile c++ code for ARM, at this point i don't care about platform versions like armv5 vs armv7a, I'm focusing on how the platform switch works for clang:
llvm-config --targets-built
ARM CellSPU CppBackend Hexagon Mips MBlaze MSP430 NVPTX PowerPC Sparc X86 XCore
but the following command doesn't work
clang++ -arch arm soft.cpp -o soft_ARM
the output is
clang-3: warning: argument unused during compilation: '-arch arm'
I have also tried gcc-like variants or other combinations like -arch=arm, -arch=armv7a, -march=armv5 but nothing seems to work.
After reading some docs i noticed that clang works for ARM only under MAC OS X / Darwin and it's not supposed to work for ARM under other OS.
How i can compile for ARM with clang and what the output of llvm-config --targets-built is really about ?
-arch is darwin-only feature. You should use -target on non-darwin platforms. Alternatively, compile llvm/target specifying target triplet or create a link from clang to -clang. In your case the target triplet would be arm-none-linux-gnueabi