How to prevent cmake adding "compatibility_version" for gcc? - android

I'm pretty new to cmake and i'm trying to cross-compile libftdi for ARM Linux (Android).
Why cmake adds "-compatibility_version" to gcc command-line which leads to error:
/softdev/arm-toolchain/bin/arm-linux-androideabi-gcc -O2 -g -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names -L/softdev/arm-libs/lib -compatibility_version 2.0.0 -current_version 2.0.0 -o libftdi1.2.0.0.dylib -install_name /Users/asmirnov/Documents/dev/src/libftdi-1.0/src/libftdi1.2.dylib CMakeFiles/ftdi1.dir/ftdi.c.o CMakeFiles/ftdi1.dir/ftdi_stream.c.o /usr/local/lib/libusb-1.0.dylib
arm-linux-androideabi-gcc: error: 2.0.0: No such file or directory
arm-linux-androideabi-gcc: error: 2.0.0: No such file or directory
arm-linux-androideabi-gcc: error: /Users/asmirnov/Documents/dev/src/libftdi-1.0/src/libftdi1.2.dylib: No such file or directory
arm-linux-androideabi-gcc: error: unrecognized option '-compatibility_version'
arm-linux-androideabi-gcc: error: unrecognized option '-current_version'
make[2]: *** [src/libftdi1.2.0.0.dylib] Error 1
make[1]: *** [src/CMakeFiles/ftdi1.dir/all] Error 2
make: *** [all] Error 2
Since i can't find "compatibility_version" command-line parameter in supported by gcc parameters list is it cmake error or cmake configuration problem?
UPDATE: problem #1 solved (hacked)
i've solved the problem by commenting the next lines in ../Modules/Platforms/Darwin.cmake:
# 4ntoine (fix for libftdi compilation using cmake)
#set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
#set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
#set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
#set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
# ...
# 4ntoine (fix for libftdi build using cmake)
#if(NOT XCODE)
# Enable shared library versioning. This flag is not actually referenced
# but the fact that the setting exists will cause the generators to support
# soname computation.
# set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
#endif()
I know it's not good especially when you are not sure what you're doing ;)
Now i have another problem #2:
cd /Users/asmirnov/Documents/dev/src/libftdi-1.0/build/src && /usr/local/Cellar/cmake/2.8.11.1/bin/cmake -E cmake_link_script CMakeFiles/ftdi1.dir/link.txt --verbose=1
/softdev/arm-toolchain/bin/arm-linux-androideabi-gcc -O2 -g -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names -L/softdev/arm-libs/lib -o libftdi1.dylib CMakeFiles/ftdi1.dir/ftdi.c.o CMakeFiles/ftdi1.dir/ftdi_stream.c.o /softdev/arm-libs/lib/libusb-1.0.so
/softdev/arm-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /softdev/arm-toolchain/bin/../sysroot/usr/lib/crtbegin_dynamic.o: in function _start:crtbrand.c(.text+0x78): error: undefined reference to 'main'
collect2: ld returned 1 exit status
make[2]: *** [src/libftdi1.dylib] Error 1
make[1]: *** [src/CMakeFiles/ftdi1.dir/all] Error 2
make: *** [all] Error 2

Related

Using SiftGPU in Android (about ndk, cmake and SSE)

Recently I am trying to use SiftGPU in Android. I am using the Linux. So, first I download a ndk and use the following code to get a standalone toolchain:
sudo sh ./build/tools/make-standalone-toolchain.sh --verbose --platform=android-15 --install-dir=/home/YourUserName/Downloads/my-tool --toolchain=arm-linux-androideabi-4.9
Then, I add the some codes to the CmakeLists.txt so it becomes:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(SIFTGPU C CXX)
set(NDK_STANDALONE_TOOLCHAIN /home/YourUserName/Downloads/my-tool/)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 15)
set(CMAKE_C_COMPILER ${NDK_STANDALONE_TOOLCHAIN}/bin/arm-linux-androideabi-gcc)
set(CMAKE_CXX_COMPILER ${NDK_STANDALONE_TOOLCHAIN}/bin/arm-linux-androideabi-g++)
set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
set(CMAKE_FIND_ROOT_PATH ${NDK_STANDALONE_TOOLCHAIN})
add_definitions("--sysroot=${NDK_STANDALONE_TOOLCHAIN}/sysroot")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-deprecated -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-deprecated -fPIC")
ADD_SUBDIRECTORY(src)
After that, I simply go to the directory of SiftGPU, create a new folder, enter it, and run:
cmake ..
Until now, everything seems ok. However, after I run the following command, well, unfortunately, it doesn't work:
make
And here is the error:
[ 9%] Building CXX object src/SiftGPU/CMakeFiles/siftgpu.dir/FrameBufferObject.cpp.o
arm-linux-androideabi-g++: error: unrecognized argument in option '-march=core2'
arm-linux-androideabi-g++: note: valid arguments to '-march=' are: armv2 armv2a armv3 armv3m armv4 armv4t armv5 armv5e armv5t armv5te armv6 armv6-m armv6j armv6k armv6s-m armv6t2 armv6z armv6zk armv7 armv7-a armv7-m armv7-r armv7e-m armv7ve armv8-a armv8-a+crc iwmmxt iwmmxt2 native
arm-linux-androideabi-g++: error: unrecognized command line option '-mfpmath=sse'
src/SiftGPU/CMakeFiles/siftgpu.dir/build.make:62: recipe for target 'src/SiftGPU/CMakeFiles/siftgpu.dir/FrameBufferObject.cpp.o' failed
make[2]: *** [src/SiftGPU/CMakeFiles/siftgpu.dir/FrameBufferObject.cpp.o] Error 1
CMakeFiles/Makefile2:103: recipe for target 'src/SiftGPU/CMakeFiles/siftgpu.dir/all' failed
make[1]: *** [src/SiftGPU/CMakeFiles/siftgpu.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
I tried to google it but I didn't get any useful result. It seems that the ndk complier is not compatible with SSE. Does anyone have any idea about this question?
Looks like their CMake files weren't meant to be cross-compiled.
arm-linux-androideabi-g++: error: unrecognized argument in option '-march=core2'
core2 is only valid for x86.
You'll need to take a look through SiftGPU's CMakeLists.txt to see if there are options for cross-compiling, and if not, just remove that flag.

How to compile and execute MPICH2 for Android

For cross compiling MPICH2 for Android.
I found the reference here
http://hex.ro/wp/projects/personal-cloud-computing/compiling-mpich2-for-android-and-running-on-two-phones/
and here
www.scientificbulletin.upb.ro/rev_docs_arhiva/fullffc_583765.
I did following
BuildRoot
Used Build Root (buildroot-2016.02) for cross compiling ARM toolchain
Target options :
Target Architecture as ARM little endian
Target binary format as ELF
Selected Toolchain as Buildroot toolchain (Internal)
Kernel headers as 3.12.x
C library as uClibc
After this make command was run.
MPICH2
mpich-3.2.tar.gz was extracted and following commands were executed
1. $ export PATH=/home/mpiuser/CrossBuild/buildroot-2016.02/output/host/usr/bin:$PATH
2. $ sudo ./configure --prefix=/home/mpiuser/CrossBuild/arm-mpich-install --disable-fortran CC=/home/mpiuser/CrossBuild/buildroot-2016.02/output/host/usr/bin/arm-linux-gcc --host=arm-linux
After this make was run for mpich-3.2, and during compilation following error was thrown :
GEN lib/libmpi.la
CXX src/binding/cxx/initcxx.lo
CXXLD lib/libmpicxx.la
lib/.libs/libmpi.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libmpicxx.la] Error 1
make[2]: Leaving directory `/home/mpiuser/CrossBuild/mpich-3.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/mpiuser/CrossBuild/mpich-3.2'
make: *** [all] Error 2
Request to please help. Thanks

Errors building tesseract Android tools

I am trying to build Tesseract for android and have been getting issues. I am following a tutorial where the following instructions have been given to build Tesseract.
cd <project-directory>
curl -O https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
curl -O http://leptonica.googlecode.com/files/leptonica-1.69.tar.gz
tar -zxvf tesseract-ocr-3.02.02.tar.gz
tar -zxvf leptonica-1.69.tar.gz
rm -f tesseract-ocr-3.02.02.tar.gz
rm -f leptonica-1.69.tar.gz
mv tesseract-3.02.02 jni/com_googlecode_tesseract_android/src
mv leptonica-1.69 jni/com_googlecode_leptonica_android/src
ndk-build -j8
android update project --target 1 --path .
ant debug (release)
Firstly there is no path at (i.e no src directory)
jni/com_googlecode_tesseract_android/src
jni/com_googlecode_leptonica_android/src
So I am not too sure where they should go, so I left them in their extracted folder.
Also when running
ndk-build -j8
I get the following errors
In file included from jni/com_googlecode_leptonica_android/pixa.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
In file included from jni/com_googlecode_leptonica_android/pix.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/readfile.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/jni.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/utilities.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/writefile.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/box.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
make: *** [obj/local/armeabi/objs/lept/pix.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [obj/local/armeabi/objs/lept/readfile.o] Error 1
make: *** [obj/local/armeabi/objs/lept/utilities.o] Error 1
make: *** [obj/local/armeabi/objs/lept/jni.o] Error 1
make: *** [obj/local/armeabi/objs/lept/writefile.o] Error 1
make: *** [obj/local/armeabi/objs/lept/pixa.o] Error 1
make: *** [obj/local/armeabi/objs/lept/box.o] Error 1
UPDATE:
Interestingly after starting again
mv tesseract-ocr jni/com_googlecode_tesseract_android/src
mv leptonica-1.69 jni/com_googlecode_leptonica_android/src
are working.
During building I get the following errors:
jni/com_googlecode_tesseract_android/src/dict/permdawg.cpp: In member function 'void tesseract::Dict::go_deeper_dawg_fxn(const char*, const BLOB_CHOICE_LIST_VECTOR&, int, const CHAR_FRAGMENT_INFO*, bool, WERD_CHOICE*, float*, float*, WERD_CHOICE*, int*, void*)':
jni/com_googlecode_tesseract_android/src/dict/permdawg.cpp:208:62: error: format not a string literal and no format arguments [-Werror=format-security]
fprintf(output_ambig_words_file_, word_str.string());
^
cc1plus: some warnings being treated as errors
make: *** [obj/local/armeabi/objs/tess/src/dict/permdawg.o] Error 1
make: *** Waiting for unfinished jobs....
I also had the same problem.
These are the steps I followed:
Downloaded the tesseract_android_tools project from github.com/alanv/tesseract-android-tools
Extracted it and moved to tesseract-android-tools via Terminal
curl -O https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
curl -O http://leptonica.googlecode.com/files/leptonica-1.69.tar.gz
tar -zxvf tesseract-ocr-3.02.02.tar.gz
tar -zxvf leptonica-1.69.tar.gz
rm -f tesseract-ocr-3.02.02.tar.gz
rm -f leptonica-1.69.tar.gz
mv tesseract-3.02.02 jni/com_googlecode_tesseract_android/src
mv leptonica-1.69 jni/com_googlecode_leptonica_android/src
I tried running android-ndk-r9 but it kept on throwing the error jni/com_googlecode_tesseract_android/src/dict/permdawg.cpp:208:62: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus.exe: some warnings being treated as errors
I modified jni/com_googlecode_tesseract_android/src/dict/permdawg.cpp line 208 from fprintf(output_ambig_words_file_, word_str.string()); to fprintf(output_ambig_words_file_, "%s", word_str.string());
I tried running android.bat update project -p . but kept on complaining that Error: The project either has no target set or the target is invalid.
Please provide a --target to the 'android.bat update' command.
I provided the target by first running android list targets to get the targets I have and then android update project -t 7 -p . since 7 was my preferred target
That worked.
Sorry for the late reply

Error while building Android V2.2[Froyo] Source Code

I'm getting the following error while building the Froyo Code -
No private recovery resources for TARGET_DEVICE passion
target Generated: libclearsilver-jni <= out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar
target Generated: libclearsilver-jni <= out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar
host C: libneo_util <= external/clearsilver/util/neo_hash.c
host Executable: acp (out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp)
/bin/bash: javah: command not found
/bin/bash: javah: command not found
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libclearsilver- jni_intermediates/org_clearsilver_CS.h] Error 127
make: *** Waiting for unfinished jobs....
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libclearsilver- jni_intermediates/org_clearsilver_HDF.h] Error 127
true
Please help me to find out the root cause for this build error.
This is probably a PATH issue. For me I had to do
export PATH=$PATH:/usr/java/jdk1.6.0_25/bin/
To make it work properly.
$ uname -m
x86_64
depending upon x86_64 or XXX32
modified the following files to use m64 for x86_64 and m32 for xxx32 in android directory
/external/clearsilver/cgi/Android.mk
/external/clearsilver/java-jni/Android.mk
/external/clearsilver/util/Android.mk
/external/clearsilver/cs/Android.mk
Edit the above mentioned files using vi or vim editor.
type
LOCAL_CFLAGS += -m64
LOCAL_LDFLAGS += -m64
command in the files below the line "LOCAL_CFLAGS := "
NOTE: If your system is x86_64 download JDK_1.5_update_xx_amd64.bin
Javah is a part of the JDK. Download and install one.

Cross compiling to arm-linux using cygwin

I am trying to cross-compile strace using cygwin to Android emulator. I used this article
as my starting point. I installed the cross-compiler following these instructions. Then I prepared the makefile using
./configure -host=arm-linux
Now when I do make I get the following error:
$ make
make all-recursive
make[1]: Entering directory `/home/bruce/strace-4.6'
Making all in tests
make[2]: Entering directory `/home/bruce/strace-4.6/tests'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/bruce/strace-4.6/tests'
make[2]: Entering directory `/home/bruce/strace-4.6'
arm-linux-gcc -DHAVE_CONFIG_H -I. -I./linux/arm -I./linux -I./linux -Wall -Wwr
ite-strings -g -O2 -MT block.o -MD -MP -MF .deps/block.Tpo -c -o block.o block.c
block.c: In function `block_ioctl':
block.c:198: error: `u64' undeclared (first use in this function)
block.c:198: error: (Each undeclared identifier is reported only once
block.c:198: error: for each function it appears in.)
block.c:271: error: `BLKTRACESTOP' undeclared (first use in this function)
make[2]: *** [block.o] Error 1
make[2]: Leaving directory `/home/bruce/strace-4.6'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/bruce/strace-4.6'
make: *** [all] Error 2
This occurs even if I append -static after CFLAGS variable in Makefile (Why do I need to do this?). Please help.
Here are the lines 198-206:
case BLKGETSIZE64:
if (exiting(tcp)) {
uint64_t val;
if (syserror(tcp) || umove(tcp, arg, &val) < 0)
tprintf(", %#lx", arg);
else
tprintf(", %" PRIu64, val);
}
break;
First of all, what's BLKGETSIZE64 #defined as?
There might be a "u64" token hiding in the definition.
Is a 64-bit int actually a well defined object as far as arm-linux-gcc is concerned? Just a thought...but it must be, right?
And the -static addition to CFLAGS causes the binary program to be linked statically, as opposed to dynamically.
That means that all the code it needs to run will be built into the executable.
Ordinarily, it would dynamically link to Shared Object libraries (.so files, DLLs under Windows), but you can't necessarily count on the particular libraries that your program needs being included in an embedded device. Rather than install all the libraries on the handheld, you can (probably) save space by just building the relevant bits into your executable.

Categories

Resources