How to upload iOS app to Appstore which uses OpenCV [duplicate] - c++

Compiling Xcode Project fails with following errors:
'missing required architecture arm64 in file /Users/*/Git/ocr/opencv2.framework/opencv2'
It works well, if i change Architectures(under Build Settings) to (armv7, armv7s) instead of (armv7, armv7s).
How to change the opencv python build script, to add arm64 support to opencv2.framework?

The latest OpenCV iOS framework supports 64 bit by default
It can be downloaded at: OpenCV download page

I modified the following to make it build, though I haven't got an arm64 iOS device to test at the moment.
Edit: I also had to follow https://stackoverflow.com/a/17025423/1094400
Assuming "opencv" is the folder containing the opencv source from Github:
in each of gzlib.c, gzread.c, gzwrite.c located in opencv/3rdparty/zlib/ add:
#include <unistd.h>
at the top after the existing include.
In addition open opencv/platforms/ios/cmake/Modules/Platform/iOS.cmake and change line 88 from:
set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)" CACHE string "Build architecture for iOS")
to:
set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_INCLUDING_64_BIT)" CACHE string "Build architecture for iOS")
Furthermore change the buildscript at opencv/platforms/ios/build_framework.py in lines 99 and 100 from:
targets = ["iPhoneOS", "iPhoneOS", "iPhoneSimulator"]
archs = ["armv7", "armv7s", "i386"]
to:
targets = ["iPhoneOS", "iPhoneOS", "iPhoneOS", "iPhoneSimulator", "iPhoneSimulator"]
archs = ["armv7", "armv7s", "arm64", "i386", "x86_64"]
The resulting library will include the following:
$ xcrun -sdk iphoneos lipo -info opencv2
Architectures in the fat file: opencv2 are: armv7 armv7s i386 x86_64 arm64
Although I have a remaining concern regarding opencv/platforms/ios/cmake/Toolchain-iPhoneOS_Xcode.cmake which defines the size of a data pointer to be 4 in lines 14 and 17.
It should be 8 for 64bit I guess, so as I haven't tested if the compiled library is working for arm64 I would suggest further investigations at this point if it does not run properly.

micahp's answer was almost perfect, but missed the simulator version. So modify platforms/ios/build_framework.py to:
targets = ["iPhoneOS", "iPhoneOS", "iPhoneOS", "iPhoneSimulator", "iPhoneSimulator"]
archs = ["armv7", "armv7s", "arm64", "i386", "x86_64"]
You'll need to download the command line tools for Xcode 5.0.1 and then run
python opencv/platforms/ios/build_framework.py ios

Try to wait a next month. Will release a new XCode with more powerful supporting of 32/64 bit.
https://developer.apple.com/news/index.php?id=9162013a

Modify "build_frameworks.py" to:
def build_framework(srcroot, dstroot):
"main function to do all the work"
targets = ["iPhoneOS", "iPhoneOS", "iPhoneOS", "iPhoneSimulator"]
archs = ["armv7", "armv7s", "arm64", "i386"]
for i in range(len(targets)):
build_opencv(srcroot, os.path.join(dstroot, "build"), targets[i], archs[i])
put_framework_together(srcroot, dstroot)

#Jan, I followed your instructions, but OpenCV still doesn't run on arm64. You made such a detailed and wonderful answer - why not check it out on a simulator and see if you can make it run? :-)
FWIW, I think it might be harder than it seems. On the openCV stackoverflow clone, there's an indication that this problem might be non-trivial.

Instead of using terminal commands given in the opencv installation guide in official website, use the following commands. Worked for me.
cd OpenCV-2.3.1
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
sudo make install

I was having a similar error, but the issue wasn't related with the arm64 coompilation.fixed adding the framework libc++.dylib

Related

Build and test V8 from AOSP for the older version on Ubuntu 18.04.5 LTS

I am trying to run the unit tests for the V8 present in the AOSP's lollipop release: external/chromium_org/v8
by following the documentation from https://v8.dev/docs/build. But the build itself is constantly failing.
Steps followed:
Export the depot_tools path
gclient sync
install dependencies using ./build/install-build-deps.sh (This script was not present by default in the source code, so had to copy manually from the higher version)
gm x64.release
I have installed all the dependencies and followed all the steps from the documentation mentioned above but when I do:
gm x64.release
the build fails with the following output:
# echo > out/x64.release/args.gn << EOF
is_component_build = false
is_debug = false
target_cpu = "x64"
use_goma = false
v8_enable_backtrace = true
v8_enable_disassembler = true
v8_enable_object_print = true
v8_enable_verify_heap = true
EOF
# gn gen out/x64.release
ERROR at //build/config/BUILDCONFIG.gn:71:7: Undefined identifier
if (os == "chromeos") {
^-
I have tried building the it with gn as well by following the manual workflow but I am ending up with the same errors. I also tried setting the os variable to linux in the gn args list but there as well I get the unknown identifier error.
I see that the v8 used in the AOSP project differs a lot in terms of files from the main source code with the same version. The helper script tools/dev/gm.py is also not present by default so I am using one from the higher version. It would be great if anyone could suggest if there's any different set of steps I should be following or any other resources I can refer to in order to build the V8 present in the AOSP project
Version: V8 3.29.88.17
OS: Ubuntu 18.04.5 LTS
Architecture: x86_64
3.29 is seriously old; I'm not surprised that it won't build with current tools. Rule of thumb: when building old software, use the tools that were used to build it back then.
In the case at hand: try make x64.release.check -jN with N being the number of CPU cores you have.
I see that the v8 used in the AOSP project differs a lot in terms of files from the main source code with the same version.
The "lollipop-release" branch contains V8 3.27.34.15, whereas "lollipop-mr1-release" contains V8 3.29.88.17 which you quoted. Does that explain the differences?

QT 32 and 64 bit rpms installed. failed dependencies. which to use?

Please help me figure out what is going on with my system. When I type
rpm -qa|grep qt
I get:
qt5-rpm-macros-5.6.2-1.el7.noarch
qt-x11-4.8.5-13.el7.i686
qt5-qtxmlpatterns-5.6.2-1.el7.x86_64
qt-creator-4.1.0-3.el7.x86_64
qt5-qtbase-gui-5.6.2-1.el7.x86_64
qt-4.8.5-13.el7.i686
qt5-qttools-libs-clucene-5.6.2-1.el7.x86_64
qt-x11-4.8.5-13.el7.x86_64
qt5-qttools-libs-designercomponents-5.6.2-1.el7.x86_64
qt5-qtdeclarative-5.6.2-1.el7.x86_64
qt5-qtdoc-5.6.2-1.el7.noarch
qt5-qtquickcontrols-5.6.2-1.el7.x86_64
dbusmenu-qt-0.9.2-7.el7.x86_64
qt-4.8.5-13.el7.x86_64
qt5-qttools-libs-help-5.6.2-1.el7.x86_64
qt5-qtwebchannel-5.6.2-1.el7.x86_64
qt5-qtbase-common-5.6.2-1.el7.noarch
qt5-qttools-common-5.6.2-1.el7.noarch
polkit-qt-0.103.0-10.el7_0.x86_64
qt5-qtwebkit-5.6.2-1.el7.x86_64
qt5-qtbase-devel-5.6.2-1.el7.x86_64
qt5-qtbase-5.6.2-1.el7.x86_64
qt5-qtsensors-5.6.2-1.el7.x86_64
qt5-qttools-libs-designer-5.6.2-1.el7.x86_64
qt-settings-19-23.5.el7.noarch
qt-devel-4.8.5-13.el7.i686
qt5-qtscript-5.6.2-1.el7.x86_64
qt-creator-data-4.1.0-3.el7.noarch
qt5-qtlocation-5.6.2-1.el7.x86_64
And a few more commands and results:
arch = x86_64
qmake --version = QMake version 2.01 Using Qt version 4.8.5 in /usr/lib
My confusion:
Why are both 32 and 64 bit rpms of qt installed?
Why do I see qt5 rpms installed on a 4.8 system?
How do I know which rpms to install when installing new libraries, 32 or 64?
I am asking because I tried to install the phonon 64 bit version and get error from pro file:
/usr/bin/ld: skipping incompatible /usr/lib64/libphonon.so when searching for -lphonon
/usr/bin/ld: cannot find -lphonon
And when I tried to install 32 bit version I get dependency issues on 12 .so files, for example:
libpulse-mainloop-glib.so.0 is needed by phonon-4.6.0-10.el7.i686
libpulse-mainloop-glib.so.0(PULSE_0) is needed by phonon-4.6.0-10.el7.i686
libpulse.so.0 is needed by phonon-4.6.0-10.el7.i686
libgstreamer-0.10.so.0 is needed by phonon-backend-gstreamer-2:4.6.3-3.el7.i686
Which I cant locate anywhere on my system. Please fill in my gaps and explain what I'm seeing if possible

Build 32 bit libcurl on 64 bit OSX

I am trying to build a 32 bit lib of curl for OSX, on a 64 bit OSX installation (Yosemite 10.10.5), according to the documentation. I've tried calling ./configure with a number of different arguments, but this is the one that I would expect to cover all bases:
CFLAGS='-m32 -arch i386' LDFLAGS='-arch i386' ./configure --host=i386-apple
I've tried different hosts as well, such as x86-apple, x86-apple-darwin, i386-apple-darwin, etc. They all build without issues, as far as I can see, but when I try to build my other 32 bit project that links to the resultant dylib, I get the following error message
warning: ignoring file [...]/libcurl.a, file was built for archive which is not the architecture being linked (i386)
And then several variations on
Undefined symbols for architecture i386:
"_curl_easy_cleanup" [...]
A call to
lipo -info libcurl.a
Yields the following result
fatal error: [...]/lipo: archive with no architecture specification: libcurl.a
What am I doing wrong? Is my ./configure call badly formed, am I missing a flag or an argument? According to the installation instructions, people have successfully compiled to i386 Mac OS X, so I'm assuming there's something I'm missing
Maybe it's late, but since I just hit the same wall... You can try specifying in configure options:
./configure --build=i386-darwin --host=x86_64-darwin
As far as I can tell, host denotes the architecture of the machine on which you are building, while build is the target architecture.

How to build clang/examples/PrintFunctionNames?

I need some simple example to start using clang.
I downloaded llvm and clang and built:
mkdir llvm-build
cd llvm-build
../llvm/configure
make
I tried to build PrintFunctionNames from clang examples but got an error message:
../../../../Makefile.common:61: ../../../../Makefile.config: No such file or directory
../../../../Makefile.common:69: /Makefile.rules: No such file or directory
make: * No rule to make target `/Makefile.rules'. Stop.
Readme file says that only make is needed.
So how to build this plugin?
Go into llvm-build/tools/clang, and run "make BUILD_EXAMPLES=1".
Most assuredly you will have your LLVM trunk checkout and under the tools path you have checked out Clang trunk as well [explained under building Clang via http://clang.llvm.org/get_started.html.
Makefile Build Guide: http://llvm.org/docs/MakefileGuide.html
On OS X the build set up is a bit different, but on Debian Linux I'm building it daily as follows:
../trunk/configure --enable-target=x86_64,arm,cpp,cbe --with-built-clang --enable-pic --enable-polly --enable-shared --with-cxx-include-arch=x86_64 --enable-optimized --with-optimize-option=-Os --enable-assertions --disable-bootstrap --disable-multilib --enable-jit --enable-threads --no-create --no-recursion
then applying the make -j (n+1 number of cores) on the command for my Pentium D 945 system:
make [building against autotools make -j (n+1) doesn't always building llvm cleanly as it does against cmake. So if you want to run all cores, expect the possibility of running make -j(n+1) more than once to result in a clean build.
Standard form without accessing multiple cores:
make BUILD_EXAMPLES='1' //Read the note below
always results in a clean build, and if it doesn't report a bug to LLVM.
Note: If you're at the top level you can svn update the llvm trunk, project-test trunk and clang trunk as follows:
make trunk
Then go and run make again now that BUILD_EXAMPLES=1 is configured ahead of time.
make BUILD_EXAMPLES='1'
NOTE: Autotools will allow one to configure the BUILD_EXAMPLES='1' but will ignore the flag when you go to run make if you don't explicitly include BUILD_EXAMPLES='1' after make on the command line.
At the top of the LLVM tree you build against running make BUILD_EXAMPLES='1' will build the LLVM specific examples, then going inside your build/tools/clang path you then must run make BUILD_EXAMPLES='1' again to build the Clang examples.
Hence:
LLVM Top:
make BUILD_EXAMPLES='1' // for LLVM examples
cd tools/clang
make BUILD_EXAMPLES='1' // for Clang specific examples
Verify the examples installing under /usr/local/bin for LLVM and /usr/local/lib/ for Clang.
If you use CMAKE the default location for the binary examples is under /usr/local/examples
I followed the instructions at http://clang.llvm.org/get_started.html with two exceptions:
My build dir is inside the source dir (i.e. cd llvm ; mkdir build), but I don't think it's relevant.
I issued cmake as so :
cd build
cmake -DLLVM_BUILD_EXAMPLES=1 -DCLANG_BUILD_EXAMPLES=1 ..
After that (and compiling of course (make -j8)) I could find the examples in the build dir :
find -iname '*printfunctionname*'
./lib/PrintFunctionNames.so
...
I tried to do something similar yesterday: get a list of methods in a class using clang and succeeded. Maybe my post helps here also. My best help was this AST Matchers tutorial.

Slow building of a Symbian Qt Project in Qt Creator. Takes over 20 minutes

I'm trying to build a moderately sized Symbian Qt project (around 100 files) using the latest released Nokia Qt SDK (Qt 4.6.3 and Qt Mobility 1.0.2).
The build for the simulator finishes in under 3 minutes, but when I build for the device, the build takes well over 20 minutes! I can forget trying to debug on the device. It is very frustrating!
My machine specs are the following:
Windows 7 32-bit
3.24GB RAM
Intel Core 2 Duo 1.86GHz
The compiler has been stuck here for over 10 minutes:
Running build steps for project AppName...
Starting: "c:/nokiaqtsdk/symbian/sdk/bin/qmake.exe" C:/QtProjects/AppName/AppName.pro -r -spec symbian-abld -after OBJECTS_DIR=obj MOC_DIR=moc UI_DIR=ui RCC_DIR=rcc CONFIG+=release
The process "c:/nokiaqtsdk/symbian/sdk/bin/qmake.exe" exited normally.
Starting: "C:/NokiaQtSDK/Symbian/SDK/epoc32/tools/make.exe" release-gcce -w
C:\NokiaQtSDK\Symbian\SDK\epoc32\tools\make.exe: Entering directory `C:/QtProjects/AppName'
bldmake bldfiles
ABLD.BAT build gcce urel
make -r -f "\NokiaQtSDK\Symbian\SDK\EPOC32\BUILD\QtProjects\AppName\EXPORT.make" EXPORT VERBOSE=-s
make[1]: Entering directory `C:/QtProjects/AppName'
Nothing to do
make[1]: Leaving directory `C:/QtProjects/AppName'
make -r -f "\NokiaQtSDK\Symbian\SDK\EPOC32\BUILD\QtProjects\AppName\GCCE.make" MAKEFILE VERBOSE=-s
make[1]: Entering directory `C:/QtProjects/AppName'
make -s -C \QtProjects\AppName-f "MAKEFILE_0Xe001827C.MK" TO_ROOT=..\.. EPOCBLD=\NokiaQtSDK\Symbian\SDK\EPOC32\BUILD\MAKEFILE_0Xe001827C\GCCE TO_BLDINF=..\..\QtProjects\AppNamePLATFORM=GCCE MAKMAKE
perl -S makmake.pl -D \QtProjects\AppName\APPNAME_0Xe001827C GCCE
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(65) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\osextensions\stdapis\" not found
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(66) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\osextensions\stdapis\sys\" not found
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(69) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\oem\" not found
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(72) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\osextensions\" not found
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(73) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\domain\osextensions\" not found
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(74) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\domain\osextensions\loc\" not found
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(76) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\domain\osextensions\loc\sc\" not found
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(77) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\domain\middleware\loc\sc\" not found
WARNING: \QtProjects\AppName\APPNAME_0Xe001827C .MMP(82) : SYSTEMINCLUDE path "\NokiaQtSDK\Symbian\SDK\epoc32\include\osextensions\stdapis\stlport\" not found
MMPFILE "\QtProjects\AppName\APPNAME_0Xe001827C .MMP"
I solved the slow compilation problem as indicated by this thread
http://discussion.forum.nokia.com/forum/showthread.php?196650-Selective-compiling&p=720040&viewfull=1#post720040
I added
SYMBIANBUILD_DEPENDENCYOFF = 1
to the project environment variables (or it could be added to Windows environment variables), and the project compilation was back to speed again.
The solution to set the environment variable 'SYMBIANBUILD_DEPENDENCYOFF = 1' as mentioned above also works for us and can result in much quicker Target (GCCE) build times.
However, be aware that you may often need to perform a full (cleaned) re-build of the source if you have modified header files, and specifically added/removed functions for classes and therefore amended the class interface. This is because using this environment variable prevents the Symbian build tools from scanning your include files for changes.
Manually deleting the relevant *.o object files from your QTSDK\Symbian\SDK\epoc32\BUILD_yourfolder_ is a way to prevent the need for a full rebuild but also ensure that affected code is rebuilt.
I believe the slow speed of the Symbian GCCE builds is due to the legacy ABLD build tools, which should be replaced by the Symbian Build System (SBS v2) soon.
I've had trouble with very slow builds due to ZoneAlarm - switching it off resulting in builds 10x quicker... Worth a try if you have an OS firewall installed.
So cool page, the slow building speed in qt creator make me very very very frustrating, I nearly give up the Qt 4.6.3 and 4.7.3, after add the system variable 'SYMBIANBUILD_DEPENDENCYOFF = 1', it is really amazing, speed back, So thanks!
By the way, there is no speed problem in qt 4.7.4 and the compiler use the sbs not the perl any more.