I'm building an android application in eclipse. I need to call a function written in C/C++.
I setup everything including NDK, cygwin, etc (ask if u need more details), but when I try to run the project, I get this error
**** Build of configuration Default for project C_Google_FaceDetect ****
C:\cygwin\bin\bash.exe C:\Android_NDK\ndk-build
cygwin warning:
MS-DOS style path detected:
C:\Documents and Settings\John Smith\eclipse_workspace\C_Google_FaceDetect
Preferred POSIX equivalent is:
/cygdrive/c/Documents and Settings/John Smith/eclipse_workspace/C_Google_FaceDetect
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
C:\Android_NDK\ndk-build: line 40: dirname: command not found
C:\Android_NDK\ndk-build: line 78: uname: command not found ERROR:
Unknown host operating system:
*** Build Finished ****
The project name is C_Google_FaceDetect
If I use cygwin to get the PATH, I get
John Smith#E-USK3631BE /cygdrive/c
$ echo $PATH
/cygdrive/c/Program Files/PC Connectivity Solution
/cygdrive/c/WINDOWS/system32
/cygdrive/c/WINDOWS
/cygdrive/c/WINDOWS/System32/Wbem
/cygdrive/c/WINDOWS/system32/nls
/cygdrive/c/WINDOWS/system32/nls/ENGLISH
/cygdrive/c/Program Files/IVI Foundation/IVI/bin
/cygdrive/c/Program Files/IVI Foundation/VISA/WinNT/Bin
/cygdrive/c/Program Files/IVI Foundation/VISA/WinNT/Bin
/cygdrive/c/Program Files/MATLAB/R2012a/runtime/win32
/cygdrive/c/Program Files/MATLAB/R2012a/bin
/cygdrive/c/Program Files/MATLAB/R2010a/runtime/win32
/cygdrive/c/Program Files/MATLAB/R2010a/bin
/cygdrive/c/Program Files/emgucv 2.1.0.793/bin
/cygdrive/c/Documents and Settings/mchi7jb2/My Documents/GLUT/lib
/cygdrive/c/OGLSDK/lib
/cygdrive/c/Program Files/Microsoft Platform SDK for Windows Server 2003 R2/Lib
/cygdrive/c/Program Files/MATLAB/MATLAB Compiler Runtime/v713/runtime/win32
/cygdrive/c/Python27/python.exe
/cygdrive/c/Program Files/QuickTime/QTSystem
/cygdrive/c/Android_NDK
/cygdrive/c/Android_NDK/build
/cygdrive/c/Program Files/Java/jdk1.7.0_04/bin
/cygdrive/c/Android_NDK
/cygdrive/c/Android_NDK/ndk-build/usr/bin
/cygdrive/c/Android_SDK/tools
/cygdrive/c/Android_SDK/platform-tools
/cygdrive/c/Android_NDK
My Android.mk file is as follows
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := C_Google_FaceDetect
LOCAL_SRC_FILES := yuv_decoder.c
include $(BUILD_SHARED_LIBRARY)
Please help
The problem is gonne when I used this
C:\cygwin\bin\bash.exe --login -i C:\Android_NDK\ndk-build
instead of this
C:\cygwin\bin\bash.exe C:\Android_NDK\ndk-build
in the eclipse build command
I found the answer there,Running Cygwin commands from batch file
maybe the problem is only gonne because I have bigger problems now I dunno
Related
I use .PHONY in android makefile,but when i use "make xx",it can not link "xx",how cause this?
here is my code
.PHONY: test
test: $(compatibility) vtslab adb echoTEST
$(call dist-for-goals,test,$(compatibility))
echoTEST:
#echo "2222"
why I can not use a make test?
it builds with error unknown target 'test',
In my jni directory, I run the following command:
$ ./libvpx/configure --target=armv7-android-gcc --disable-examples --sdk-path=/home/peter/adt/android-ndk-r9/
This results in generating Android.mk in libvpx/build/make directory
Next, I create Android.mk in jni directory:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include libvpx/build/make/Android.mk
When I run ndk-build, it ends up creating libvpx.so.
However, I would really like to create a static library.
I started all over and ran the configuration with an extra flag:
$ ./libvpx/configure --target=armv7-android-gcc --disable-examples --sdk-path=/home/peter/adt/android-ndk-r9/ --enable-static
However, running ndk-build still results in creating libvpx.so.
Does any know how I can configure libvpx to create a static library? Thank you in advance for your help.
I was able to successfully build an arm static library, though I have not yet integrated it with an Android application as I am building libvpx as a component for another native library.
Note that in my case the Android.mk already existed in the directory tree and was unaffected by the configure script, which is apparently contrary to your experience. To build the static library I simply invoked configure and then make:
$ make clean
$ ./configure --target=armv7-android-gcc --disable-examples --sdk-path=/home/me/android-ndk-r9b/
$ make
In my case I had to do a clean build because I had some cruft left from an earlier build attempt that would break the build otherwise.
The result is libvpx.a and libvpx_g.a.
To build the JNI shared library, you will need to have installed the Android NDK and set up the proper environment variables such as ANDROID_NDK_ROOT.
cd /Platinum
scons target=arm-android-linux build_config=Release
cd /Platinum/Source/Platform/Android/modules/platinum/jni
ndk-build NDK_DEBUG=0
import eclipse Android .project located # /Platinum/Source/Platform/Android/modules/platinum/
This will create the jar file # /Platinum/Source/Platform/Android/modules/platinum/bin/platinum.jar
The readme is above of building the platinum with ndk-build.
First step, command: "scons target=arm-android-linux build_config=Release", already succeeded.
Second step, command: "ndk-build NDK_DEBUG=0", failed. The failed log is below.
wingyip#ubuntu:~/Desktop/PlatinumKit-1-0-3-0_a71192_66de97/Platinum/Source/Platform/Android/module/platinum/jni$ ndk-buildStaticLibrary : libstdc++.aSharedLibrary : libplatinum-jni.so/home/wingyip/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -laxTls/home/wingyip/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/wingyip/Desktop/PlatinumKit-1-0-3-0_a71192_66de97/Platinum/Source/Platform/Android/module/platinum/jni/../../../../../../Build/Targets/arm-android-linux/Release/libNeptune.a(NptTls.o): in function NPT_TlsContext::~NPT_TlsContext():NptTls.cpp(.text._ZN14NPT_TlsContextD1Ev+0x18): error: undefined reference to 'ssl_ctx_free'
System: ubuntu
NDK version: android-ndk-r8c
I found this problem too. It's just a typo, open Android.mk then change
LOCAL_LDLIBS += -laxTls
to:
LOCAL_LDLIBS += -laxTLS
You can see the lib's name is libaxTLS.a.
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
I am following the steps on http://developer.android.com/sdk/ndk/overview.html to build the hello-jni sample, however when I get to Step 2 to run
cd $NDK-ROOT/samples/hello-jni
$NDK-ROOT/ndk-build
in the Cygwin command prompt, I receive the following error messages:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
Android NDK: Host awk tool is outdated. Please define HOST_AWK to point to Gawk
or Nawk !
I have Cygwin 1.7.9, Gnu Make 3.8.2, and Gawk 3.1.8 on my Windows machine, along with the r5b release of the Android NDK.
I also have set the HOST_AWK environment variable, which points to my Gawk folder.
Unfortunatley the sample cannot run successfully without this step, (if I run hello-jni, I immediately receive an UnsatisfiedLinkError exception).
Below is the portion of the init.mk file on my machine (found in NDK_ROOT/build/core) which creates this error:
# Location of all awk scripts we use
BUILD_AWK := $(NDK_ROOT)/build/awk
AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk)
$(call ndk_log,Host awk test returned: $(AWK_TEST))
ifneq ($(AWK_TEST),Pass)
$(call __ndk_info,Host awk tool is outdated. Please define HOST_AWK to point to Gawk or Nawk !)
$(call __ndk_error,Aborting.)
endif
Thank-you for your help
Try updating your awk tool. Seems to an an outdated version (perhaps). Also ensure that NDK root is defined to where you have your NDK source and ensure that your awk tool is located in the build directory of your NDK Source.
NDK_ROOT
Try settings this environment variable to where your NDK root is. Whenever this is defined (Typically at the top)
Instead of HOST_AWK=gawk.exe, just do HOST_AWK=gawk
It turns out there was an apostrophe in my HOST_AWK path, which was causing the problem.
reference
https://stackoverflow.com/q/8121153/411522
mine worked fine now.what to do is: just rename the prebuilt awk in ndk