Cross-compiling nfs-utils package for Android - android

I would like to add NFS support (both client and server) for my Android device. I have already built and inserted the required kernel modules (sunrpc.ko, lockd.ko, nfs.ko, exportfs.ko, nfsd.ko)
My Android phone now can act as an NFS client by mounting using Busybox. But to work as an NFS server, seems like some utilities (such as exportfs) and service daemons (portmap, nfsd, mountd, etc) are missing.
I figured I needed to install the nfs-utils package (http://nfs.sourceforge.net/).
I thought I should cross-compile it on my pc and then install it on my phone's Linux kernel. I'm not familiar with the whole cross-compiling thing. I'm trying to compile it on Ubuntu right now, and this is the command I'm using:
$ ./configure
--target=arm-linux-gnueabi
--host=arm-linux-gnueabi
--build=x86_64-linux
CC=/usr/bin/arm-linux-gnueabi-gcc
CPPFLAGS="-I/usr/arm-linux-gnueabi/include/"
CFLAGS="-nostdlib"
LDFLAGS="-Wl,-rpath-link=/usr/arm-linux-gnueabi/lib/ -L/usr/arm-linux-gnueabi/lib/"
LIBS="-lc"
This gives me the error msg:
checking for libwrap... configure: error: *** libwrap missing
config.log errors:
configure:3978: /usr/bin/arm-linux-gnueabi-gcc -V >&5
arm-linux-gnueabi-gcc: fatal error: no input files
configure:3978: /usr/bin/arm-linux-gnueabi-gcc -qversion >&5
arm-linux-gnueabi-gcc: fatal error: no input files
conftest.c:12:28: fatal error: ac_nonexistent.h: No such file or directory
conftest.c:55:28: fatal error: sys/capability.h: No such file or directory
I have the gcc-arm-linux-gnueabi package installed, but I guess there are some problems with building/linking with dependency libraries I don't really understand. Should they be cross-compiled too? How can I do that? And will I need to insert these libraries into my phone for NFS to run properly?
I'm completely new to this so any help would be greatly appreciated.

You have a dependency of tcp-wrappers which means you must first build and install tcp wrappers.
Alternatively, you can pass this option to ./configure:
--without-tcp-wrappers \
Also, you can get a complete list of options:
./configure --help

Related

Error when building Qt5.13.2 from source on Windows for Android

I have a problem while trying to build Qt 5.13.2 from source for Android.
I have used PowerShell on Windows 10.
Before configure command I have set JDK_ROOT path:
set "JDK_ROOT=C:\Program Files\Java\jdk1.8.0_241\bin
This configure command is executed successfully:
..\src\qt5\configure -prefix E:\Qt\Static\Qt5.13.2Android -platform win32-g++ -opengl es2 -xplatform android-clang -android-sdk C:\Users\user\AppData\Local\Android\Sdk -android-ndk C:\Users\user\AppData\Local\Android\Sdk\ndk\21.3.6528147 -nomake tests -nomake examples -opensource -confirm-license
After this I execute:
mingw32-make -j4
and shortly after start the build stops with this output at the end:
del ..\..\..\lib\libQt5Bootstrap.a 2>NUL
ar -rc ..\..\..\lib\libQt5Bootstrap.a #object_script.libQt5Bootstrap.Release
mingw32-make[4]: Leaving directory 'E:/Qt/Static/build-android/qtbase/src/tools/bootstrap'
mingw32-make[3]: Leaving directory 'E:/Qt/Static/build-android/qtbase/src/tools/bootstrap'
mingw32-make[2]: Leaving directory 'E:/Qt/Static/build-android/qtbase/src'
mingw32-make[1]: *** [Makefile:51: sub-src-make_first] Error 2
mingw32-make[1]: Leaving directory 'E:/Qt/Static/build-android/qtbase'
mingw32-make: *** [Makefile:87: module-qtbase-make_first] Error 2
Any suggestion or idea why build stops? Thanks in advance.
UPDATE: Same happens with Qt 5.14.2 and Qt 5.12.5
The documentation for make says that the-j option tells it to divide up the work into multiple "jobs" that run in parallel. That is helpful because it completes faster that way. But the output becomes more confusing as each job writes to the same console and you can't easily tell which output comes from which job. So when you get a compile error, it's often hard to find what the error message actually is. So when I get an error, I usually remove the -j option so that the output stays sequential and I can actually read it.
Note: You wrote in the comments that simply removing this option allowed qt to compile successfully, so that's why I'm writing this as an answer. But I really don't know why that would help. Maybe there's something that was getting compiled out of order with the multiple jobs. Anyway, I'm glad this answer helped you.

`gomobile build` and `gomobile install` throws "gomobile: EOF"

I'm trying to build an android application using gomobile but the commands gomobile install and gomobile build fail with gomobile: EOF . Before this error I was getting this error:
# golang.org/x/mobile/gl
In file included from /root/go/src/golang.org/x/mobile/gl/gl.go:17:0:
work.h:6:23: fatal error: GLES2/gl2.h: No such file or directory
compilation terminated. but it was fixed with yum install make gcc mesa-libGLES-devel mesa-libEGL-devel.
The application is mostly a networking application. Here are the imports. Do only certain packages work with gomobile or all of them?
"golang.org/x/mobile/app"
"golang.org/x/net/websocket"
"os/exec"
"flag"
"fmt"
log "github.com/golang/glog"
"io/ioutil"
"net"
"net/http"
"net/url"
"strconv"
OS: Fedora 22.
More info: I'm able to build https://github.com/golang/mobile/blob/master/example/network/main.go so I can only assume the issue is specific to my application.
It failed because AndroidManifest.xml was empty.

Building OpenSSL for Android (ARMv7) on Win32

How can I build OpenSSL for Android ARM v7 (using Android NDK) on Win32?
Until the OpenSSL's wiki and setenv-android.sh are updated accordingly, I'll publish the recipe here. The required fixes to the process are:
Update setenv-android.sh to support Windows.
Update PATH to use Android NDK's (mingw) GNU make (rather than Cygwin's).
Invoke make with a Windows-style path to Cygwin's perl.
This recipe will be a strange hybrid of Cygwin and mingw (since Android NDK gcc toolchains for win32 are mingw). I'm assuming a Windows x86_64 build of the Android NDK unpacked into c:\android-ndk-r9d, and that you wish to use a gcc 4.8 toolchain.
Install Android NDK (duh!).
Install Cygwin -- make sure to include perl
Start Cygwin shell as an administrator to make sure native symlinks will work.
Within the console, run the following script to set the variables:
export \
CYGWIN=winsymlinks:native \
ANDROID_API=android-14 \
ANDROID_DEV=c:/android-ndk-r9d/platforms/android-14/arch-arm/usr \
PATH=/cygdrive/c/android-ndk-r9d/prebuilt/windows-x86_64/bin:/cygdrive/c/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin:$PATH \
MACHINE=armv7 \
SYSTEM=android \
ARCH=arm \
CROSS_COMPILE=arm-linux-androideabi-
Now, unpack openssl:
tar xzfv openssl-1.0.1i.tar.gz (or whatever your tarball is)
cd openssl-1.0.1i (or whatever your version is)
Make sure you have actual native Win32 (!) symlinks in include/openssl:
cmd /c "dir include\openssl"
You should see something like:
13-Aug-14 05:59 PM <SYMLINK> aes.h [..\..\crypto\aes\aes.h]
13-Aug-14 05:59 PM <SYMLINK> asn1.h [..\..\crypto\asn1\asn1.h]
(etc.)
Now it's time to configure:
./config shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir=/foo/bar
Ignore the failure to build (due to failure to find perl). We'll rectify this right away. Do this:
make PERL=$(cygpath -w $(which perl))
Now wait for a few minutes until it builds, and presto, you have your libcrypto.so etc.
Just a couple of comments on my experience with this:
Executing this statement:
PERL=$(cygpath -w $(which perl))
in the cygwin shell allows the shell to interpret the backslashes as escape characters and the build process chokes. To solve this I did the following:
$ echo $(cygpath -w $(which perl))
which produced the windows formatted path to the perl executable:
C:\cygwin64\bin\perl
Then I added this line to the export shown above:
PERL=c:/cygwin64/bin/perl \
There are other ways of doing this, but it worked and headed off the problem with the ./config statement documented above (not finding perl).
Second issue was the -no- statements. After running the configure, the script reports that you'll have to run make depend. I wanted to exclude MD5 (i.e. -no-md5) and when I did the make depend, it errored out with a report that MD5 was disabled. Uhhh, yes, that was kind of the idea, but I just won't use MD5 hashes. I did use the -no-ssl2 and didn't get any complaints after the make depend.
Third issue and this is a mystery. The build broke on compiling crypto because it could not find a symbol that is supposed to be defined in /crypto/objects/obj_xref.h. When I looked at the file, it was empty. Something in the perl script I suppose, but no time to debug right now, since I'm at proof of concept phase. I placed a copy from a patch that I picked up at https://github.com/devpack/openssl-android
After that, my build ran to completion. I've done no testing with this and it is not a trustworthy solution, but it did compile and produce the static libraries that I need for proof of concept for my client.
Just as an update, my shared library built with these libraries loaded fine on my target.

How to get libreadline for Android?

I tried to download the gnu readline-6.2 source code but could not manage to build it on Android platform. Could anyone point out a way for me to tackle this problem? Thanks a lot!
I try to get the default Android build flags on my PC and use it to run ./configure and got problems saying that:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-linux-androideabi
configure: cross-compiling for arm-linux-androideabi is not supported
Beginning configuration for readline-6.2 for arm-linux-androideabi
checking whether make sets $(MAKE)... yes
checking for arm-linux-gcc... /home/huangwei/ICS/prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-gcc
checking for C compiler default output file name...
configure: error: in `/home/huangwei/ICS/external/readline':
configure: error: C compiler cannot create executables
See `config.log' for more details.
However, I opened the config.log and use the same build command to compile the conftest.c, it works, the .o file is there. I don't know why the configure still fails. Is there anyone could help?
I found myself also needing to compile libreadline for arm-linux-androideabi. What I did was the following:
download source code for libreadline gnu.
set CC to the android-ndk cross compiler (CC=~/android/lib/bin/arm-linux-androideabi-gcc)
update the config.sub and config.guess files (the ones in the libreadline source are very old and don't have arm-linux-androideabi)
$ cp /usr/share/misc/config.{sub,guess} support/.
run ./configure with --host and --prefix set to the target architecture and the locations for the compiled objects
$ CC=~/android/lib/bin/arm-linux-androideabi-gcc ./configure --build=arm-linux-androideabi --prefix=~/android/lib/
make && make install and it worked for me! I have libreadline.a and libreadline.so files in ~/android/lib/lib
Note, before I had updated the support/config.sub and support/config.guess files I was getting the same error described in the question.

configure: error: C compiler cannot create executables when configuring for Android

I have downloaded the CPP Unit Test framework and trying to compile for the Android. But, facing the Configure issues. I tried making Standalone tool chain and also tried configuring but its always failing
sh-4.1$ ./configure CXX=arm-linux-androideabi-g++ CC=arm-linux-androideabi-gcc CPP=arm-linux-androideabi-g++ CXXCPP=arm-linux-androideabi-g++
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make sets $(MAKE)... (cached) yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... arm-linux-androideabi-gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
sh-4.1$ arm-linux-androideabi-g++
arm-linux-androideabi-g++.exe: fatal error: no input files
compilation terminated.
sh-4.1$
My build environment is NDKr8, Cygwin, Windows7-x64.
I tried going through the config.log and found that the error is
arm-linux-androideabi-gcc.exe: error: CreateProcess: No such file or directory
I tried for fixing the above error by cutting down the path length and so on. But still not able to resolve. Please let me know if anyone has resolved similar problem.
Just to add the information from the link http://curl.haxx.se/mail/lib-2012-08/0184.html
but facing same issue with out Cygwin as well.
D:\Test>arm-linux-androideabi-gcc Main.c
arm-linux-androideabi-gcc: error: CreateProcess: No such file or directory
D:\Test>
As you observer even in the windows prompt as well it is the same issue.
----- Edit 1 -----
I tried configuring on the Ubuntu 12.04 OS with the below line
./configure --host=arm CXX=arm-linux-androideabi-g++ CC=arm-linux-androideabi-gcc CPP=arm-linux-androideabi-g++ CXXCPP=arm-linux-androideabi-g++
But getting these errors
checking how to run the C preprocessor... arm-linux-androideabi-g++
configure: error: in `/mnt/hgfs/VMShare/gperftools-2.0_Android/gperftools-2.0':
configure: error: C preprocessor "arm-linux-androideabi-g++" fails sanity check
See `config.log' for more details.
But most of the times ARM android Gcc compiler is failing.
configure:4216: arm-linux-androideabi-gcc -qversion >&5
arm-linux-androideabi-gcc: error: unrecognized option '-qversion'
arm-linux-androideabi-gcc: fatal error: no input files
Give the correct path and environment.
Example setup:
export NDK=/develop/android/android-ndk-r9b
export SYSROOT=$NDK/platforms/android-18/arch-x86
export CC="$NDK/toolchains/x86-4.7/prebuilt/linux-x86/bin/i686-linux-android-gcc --sysroot=$SYSROOT"
export CFLAGS="--sysroot=$SYSROOT "
export LDFLAGS="--sysroot=$SYSROOT "
I don't have experience with your particular setup, but when I was getting this error, I fixed it by adding gcc's bin folder to the system path and additionally, there had to be a version of each executable without a prefix (for example g++.exe, ld.exe...) in the gcc's bin directory. This solved the issue for me. I also logged off/on after changing the path, but don't know if it's necessary.
I got the idea here:
http://forums.codeblocks.org/index.php?topic=18100.0

Categories

Resources