i'm trying to use Google's v8 in my iPhone Application.
I built the libraries using "make arm" as stated on Google's website.
Unfortunately I get several linker errors telling me that the library is build "for archive".
The terminal tells me that the library's architecture is i386:
lipo -info libv8_base.a
input file libv8_base.a is not a fat file
Non-fat file: libv8_base.a is architecture: i386
So, how do I actually build a armv7 library?
BTW: I don't really know much about this library building stuff. Maybe I can only build for ARM on an actual ARM device? I don't get why I can't just download the prebuilt files anywhere, too.
You can find instructions to cross-compile for ARM on the v8 wiki.
When running on an x86 machine
make arm
builds a simulator, not an actual ARM binary.
You can also compile a release shell natively if you have ARM hardware:
scons arch=arm -j2
EDIT:
You may also want to learn about cross-compilation.
There is a simulator for armv7 built in the v8 source. If you check v8/src/arm/ you will find simulator files.
To build, make sure your CC, CXX and LINK are point to native gcc / g++ tools. And then do
Make arm.release -j8
This will make for arm and look into *.gypi files for more build options. Hope this is useful.
Related
I've been trying to cross-compile a static C library for use in an iOS application.
I figured that this can be achieved by wrapping the headers and binaries in an XCFramework, but the compiled library is for an x86_64 architecture, so it can't run on iOS.
What I did was the following:
export IOS_SDK_LOC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
export AARCH64_FLAGS="-arch arm64 -isysroot $IOS_SDK_LOC "
./configure --host=arm_apple_darwin --build=x86_64_apple_darwin --target=x86_64_apple_darwin
\ CFLAGS=$AARCH64_FLAGS CPPFLAGS=$AARCH64_FLAGS
I initially tried to just have the CFLAGS, but ended up passing the same arguments as CPPFLAGS as well following the answer at Can't cross compile C library for arm (iOS)
In either case, I get the same error:
configure: error: cannot run test program while cross compiling
How should I go about compiling my library in this case?
The workaround I found for compiling an arm64 static library on the same machine was to install QEMU (machine emulator), with the target OS in mind.
As luck would have it, Jonathan Afek from Aleph Security recently wrote a frame buffer for iOS QEMU, making it particularly easy to work with now.
More information here: https://www.reddit.com/r/jailbreak/comments/kxr0v8/news_ios_qemu_is_getting_a_graphical_display_ios/
I've build OpenCV 3.2.0 with contrib for iOS. Everything works nice, but when I want to use the MultiTracker class (from libopencv_tracking) and run the project on a physical device i get this warning:
*Ignoring file /libopencv-tracking.dylib, file was build for x86_65 which is not the architecture being linked (arm64)*
Because the project can't be linked with the library, it can't find reference to that class, hence some errors.
If I run in a terminal 'lipo -info libopencv_tracking.3.2.dylib' i see that the architecture is x86_64 and i have no Idea why. I never explicitly set the architecture to be like this.
I really searched the last day and none of the answers helped me. Thank you!
The README claims it can compile to armv7, but I cannot find the magic incantation to make it work.
I started down the rabbit hole of changing the Makefile to set the arch=armv7, fixing the resulting compilation errors, etc, but that doesn't seem like the right way to go about it.
There recommended cmake flags are:
cmake -DLLVM_TARGETS_TO_BUILD="X86;ARM;NVPTX" -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release ..
But alas, the bin directory contains only a .a and a .so, both of which are compiled for x86_64. There are no dylibs.
I can successfully run the test iOS app in the simulator, linking with the x86 libraries, but I cannot build on a device since there are no arm binaries.
Here is a link to the Halide test app I'm trying to build:
https://github.com/halide/Halide/tree/master/apps/HelloiOS
You should use AOT compilation for iOS. The JIT in principle works on ARM (the architecture), but not on iOS (the OS).
Clarification: are you trying to build Halide to run on ARM, or merely to generate code for ARM? (If the latter, any target will do, as all builds of Halide can generate code for all known targets.)
I need a network library for my c library so I can use it on both iOS and android. I've been searching around and tried to build libcurl as a static library but wasn't successful.
I built it with the following settings
$ export CC="clang"
$ export CFLAGS="-Wall -g -std=c11 -pipe -Os -gdwarf-2"
$ ./configure --enable-static
make install
It runs fine when I test the library with my test.c library. However, when I run it on my iOS project, I got a mismatch on CurlchkszEQ(long, CURL_SIZEOF_LONG)
I think the problem was that CURL_SIZEOF_LONG is set to be 8 while long in iOS is 4.
Does anyone know what went wrong with my config setting?
You want to cross-compile libcurl for iOS but the problem here is that you use clang which by default produces 64-bit x86_64 object files.
In other words you need to work with the iOS toolchain (xcrun -sdk iphoneos clang), provide the right architecture flag(s)[1] (e.g -arch armv7) and use the right sysroot path.
I recommend you to refer to:
curl-ios-build-scripts: a collection of handy scripts used to build (lib)curl for iOS 5+ and OSX 10.7+,
or, http://seiryu.home.comcast.net/~seiryu/libcurl-ios.html which provides a ready-to-use a precompiled binary.
[1]: you may want to produce a fat library that targets ARMv7, ARMv7s and i386 (simulator) architectures.
I have an opencv project that I've been developing under ubuntu 12.04, on a parellels VM on a mac which has an x86_64 architecture. There have been many screen switching performance issues that I believe are due to the VM, where linux video modes flip around for a couple seconds while camera access is made by the opencv application. I decided to moved the project into Xcode on the mac side of the computer to continue the opencv development. However, I'm not that familiar with xcode and am having trouble getting the project to build correctly there.
I have xcode installed.
I downloaded and decompressed the latest version of opencv on the mac, and ran: ~/src/opencv/build/cmake-gui -G Xcode .. per the instructions from willowgarage and various other locations.
This appeared to work fine (however I'm wondering now if I'm missing an architecture setting in here, although it is 64-bit intel in Xcode).
I then setup an xcode project with the source files from the linux project and changed the include directories to use /opt/local/include/... rather than the /usr/local/include/...
I switched xcode to use the LLVM GCC compiler in the build settings for the project
then set the Apple LLVM Dialog for C++ to Language Dialect to GNU++11 (which seems possibly inconsistant with the line above)
I'm not using a makefile in xcode, (that I'm aware of - it has its own project file...)
I was also running into a linker issue that looked like they may be resolved with the addition of this linker flag:
-lopencv_video
based on a similar posting here: other thread
however in that case the person was using a Makefile in their project.
I've tried adding this linker flag under "Other Linker Flags" in xcode build settings but still get build errors.
I think I may have two issues here, one with the architecture settings when building the opencv libraries with Cmake, and one with the linker flag settings in my project.
Currently the build error list looks like this:
Undefined symbols for architecture x86_64:
"cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
_main in main.o
"cv::_OutputArray::_OutputArray(cv::Mat&)", referenced from:
_main in main.o
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in main.o
"cv::Mat::copySize(cv::Mat const&)", referenced from:
cv::Mat::Mat(cv::Mat const&)in main.o
cv::Mat::operator=(cv::Mat const&)in main.o
"cv::Mat::Mat(_IplImage const*, bool)", referenced from:
_main in main.o
"cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
_main in main.o
---SNIP---
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Can anyone provide some guidance on what to try next?
Thanks,
Walt
steps to compile and run c++ opencv 2.4.4 on mac os x lion 10.7.5 with cmake 2.8.10 and xcode 4.6.1
EDIT: successfully tested with opencv 2.4.5 on mac os x mountain lion 10.8.3 and Xcode 4.5
Having the right tools
download opencv-unix from http://sourceforge.net/projects/opencvlibrary/files/ and untar it wherever
download cmake .dmg from http://www.cmake.org/cmake/resources/software.html and install it
i am assuming you have xcode 4.6 on os x lion which includes the ios sdk 6.1
go to xcode preferences to download and install the Command Line Tools so you have g++ etc.
Use cmake to compile opencv
go to the extracted opencv folder
create a build directory
mkdir build
cd build
cmake -D WITH_TBB=OFF -D BUILD_NEW_PYTHON_SUPPORT=OFF -D BUILD_FAT_JAVA_LIB=OFF -D BUILD_TBB=OFF -D BUILD_EXAMPLES=ON -D CMAKE_CXX_COMPILER=g++ CMAKE_CC_COMPILER=gcc -D CMAKE_OSX_ARCHITECTURES=x86_64 -D BUILD_opencv_java=OFF -G "Unix Makefiles" ..
make -j8
sudo make install
from the build folder, go to bin/ and run one of the tests
./opencv-test-photo
Create your own c++ opencv xcode project
fire up xcode and create a new xcode project
select Command Line Tool for the type of project under os x
open your project's build settings
under Architectures, set Architecture to 64-bit intel. also set Valid Architectures to x86_64
under Build Options, set Compiler for C/C++ to Default Compiler
under Search Paths, set Header Search Paths to /usr/local/include
also under Search Paths, set Library Search Paths to /usr/local/lib
under Apple LLVM compiler 4.2 - Language set C++ Standard Library to libstd++ (With OpenCV 2.4.6, Xcode 5, LLVM 5.0, and 10.8.5, set both language dialect and std library to "Compiler Default" instead)
Add the compiled opencv libraries to your project
go the the Build Phases tab next to Build Settings tab you were in
inside Link Binary With Libraries, click on the + sign and choose Add Other
hit the front slash / on your keyboard and enter /usr/local/lib
hit enter and select the libraries you want to use in your project
make sure you always select libopencv_core.2.4.4.dylib
hit enter and you will see the selected dylibs under your project
write some code
first lets organize the files, right click on your project blueprint icon and select New Group
name the new group opencv or whatever
drag the dylibs and drop them in that group
open main.cpp
copy code from any of the sample tests that came with opencv and paste it here
make sure all the required dylibs are added, for example, if you copied the opencv_test_stitching.cpp code into main.cpp, you will need to add the following libraries in the previous steps
libopencv_core.2.4.4.dylib
libopencv_highgui.2.4.4.dylib
libopencv_stitching.2.4.4.dylib
Cheers.