Cross compiling to arm-linux using cygwin - android

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.

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.

Cross-compiling GLibC 2.24 fails with Error 1

I am trying to cross-compile GLibC 2.24 for ARM (Android) with the gcc-arm-linux-androideabi compiler. Here is the ./configure syntax I used:
../glibc-2.24/configure --prefix=/usr --host=arm-linux-androideabi --with-headers=/usr/include
However, when I run make, it fails with the following error:
In file included from
../sysdeps/arm/libc-tls.c:19:0:
../csu/libc-tls.c: In function '__libc_setup_tls':
../csu/libc-tls.c:191:1: error: '__ARM_NR_set_tls' undeclared (first use in this function)
../csu/libc-tls.c:191:1: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [/home/red/glibc-build/csu/libc-tls.o] Error 1
make[2]: Leaving directory `/home/red/glibc-2.24/csu'
make[1]: *** [csu/subdir_lib] Error 2
make[1]: Leaving directory `/home/red/glibc-2.24'
make: *** [all] Error 2
I browsed the web on why it happened, didn't find anything. What could be the cause of this error?
I am running Ubuntu 14.04.5 LTS 64-bit.
I am running Ubuntu 14.04.5 LTS 64-bit.
That is a meaningless statepement. 64-bit what? Is it sparc64, aarch64, x86_64, something else?
Most likely you are using x86_64. In that case, you are using configure all wrong. The --host=arm-linux-androideabi tells configure that you are building on an ARM linux machine, which couldn't be further from the truth.
What you likely mean is that you want to build for arm-linux-androideabi target, and in that case the correct configure command is something like:
configure --target=arm-linux-androideabi --prefix=/usr ...
Your --with-headers setting is also very likely to be incorrect: you almost certainly don't want to use /usr/include from x86_64 host to build for arm target.

Building PJSIP: "Make dep" command giving error on Windows7

I have followed all the steps written in the pjsip-startup guide.
But the last step (make dep && make clean && make) is giving me the following errors. I am on Windows 7.
$ make dep && make clean && make
for dir in pjlib/build pjlib-util/build pjnath/build third_party/build pjmedia/b uild pjsip/build pjsip-apps/build ; do \
if make -C $dir dep; then \
true; \
else \
exit 1; \
fi; \
done
make[1]: Entering directory '/cygdrive/d/android/pjproject-2.2.1/pjlib/build'
make -f /cygdrive/d/android/pjproject-2.2.1/build/rules.mak APP=PJLIB app=pjlib depend
make[2]: Entering directory '/cygdrive/d/android/pjproject-2.2.1/pjlib/build'
.pjlib-arm-unknown-linux-androideabi.depend:1: *** multiple target patterns. St op.
make[2]: Leaving directory '/cygdrive/d/android/pjproject-2.2.1/pjlib/build'
Makefile:88: recipe for target 'depend' failed
make[1]: *** [depend] Error 2
make[1]: Leaving directory '/cygdrive/d/android/pjproject-2.2.1/pjlib/build'
Makefile:14: recipe for target 'dep' failed
make: *** [dep] Error 1
Can someone help me to resolve these errors? Thanks!
After some research I come to know that don't use WINDOWS for building the PJSIP v2.x version. Now I am going to install Ubuntu on my system.
The build system is known to work on the following hosts:
Linux, many types of distributions.
MacOS X 10.2 mingw (Win2K, XP)
FreeBSD (must use gmake instead of make)
Building Win32 applications with Cygwin is currently not supported by the autoconf script (there are some conflicts with Windows headers), but one can still use the old configure script by calling ./configure-legacy. More over, cross-compilations might also work with Cygwin using this build system.
See the link for details.

How to prevent cmake adding "compatibility_version" for gcc?

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

Configuration error of the GMP library for the android platform

I'm trying to compile GMP for android (arm) but I'm received a very strange error. First, I set up a few things as described another SO question here:
export NDKROOT=/prod/ndk
$NDKROOT/build/tools/make-standalone-toolchain.sh --platform=android-9 -- install-dir=$NDKROOT/android_armeabi
export CC="$NDKROOT/android_armeabi/bin/arm-linux-androideabi-gcc --sysroot=$NDKROOT/android_armeabi/sysroot"
export CXX="$NDKROOT/android_armeabi/bin/arm-linux-androideabi-g++ --sysroot=$NDKROOT/android_armeabi/sysroot"
export AR="$NDKROOT/android_armeabi/bin/arm-linux-androideabi-ar"
export SYSROOT="$NDKROOT/android_armeabi/sysroot"
export PATH="$NDKROOT/android_armeabi/bin":$PATH
Then I simply run ./configure --enable-cxx --prefix=/local/to/where/i/want/to/install --host=arm-none-linux-gnueabi and configuration goes well, with the following being part of the output:
Version: GNU MP 5.1.1
Host type: arm-none-linux-gnueabi
ABI: standard
Install prefix: /location/to/where/i/want/to/install
Compiler: /prod/ndk/android_armeabi/bin/arm-linux-androideabi-gcc -- sysroot=/prod/ndk/android_armeabi/sysroot -std=gnu99
Static libraries: yes
Shared libraries: yes
Up to here it goes well, but when I run make, I receive the following error:
ismpf.cc: In function 'std::istream& operator>>(std::istream&, mpf_ptr)':
ismpf.cc:48:43: error: 'struct lconv' has no member named 'decimal_point'
make[2]: *** [ismpf.lo] Error 1
make[2]: Leaving directory `~/Downloads/gmp-5.1.1/cxx'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `~/Downloads/gmp-5.1.1'
make: *** [all] Error 2
So my first problem is there. Any ideas?
Just out of curiosity, I tried to rerun the same exact configure command as above but using sudo ahead of it. After a few seconds I receive the following:
configure: error: Oops, mp_limb_t is 64 bits, but the assembler code
in this configuration expects 32 bits.
There is the second (and really weird problem that arises).
Just out of curiosity again, I tried to reboot and clear all the variables we created, and simply run the command that the GMP manual recommends:
./configure --prefix=/location/ --enable-cxx --host=arm-linux-androideabi
The ./configure runs, the make goes well, but all 9/9 tests fail when I do make check. Can anybody point me in the right direction with these errors, or about how to try and correctly compile GMP for android? Any help is immensely appreciated.
Unsetting the CFLAGS env var solved the problem for me.

Categories

Resources