This page has instuctions for compiling iwlist and other commands for Android:
https://code.google.com/p/haggle/wiki/WirelessTools
Unfortunately I'm getting the same type of error as the commenter on that page:
Android NDK: WARNING: Unsupported source file extensions in /home/simon/Android-SDK/wireless_tools.29/Android.mk for module iwlist Android NDK: iwlib.h
When I remove the iwlib.h from the LOCAL_SRC_FILES of the Android.mk, it doesn't show that warning, but it still fails with the same error:
./iwlist.c:633:7: error: 'IW_EV_LCP_PK2_LEN' undeclared (first use in this function)
This is undeclared because it is in the iwlib.h file it's warning about.
So why does the Android NDK not recognize header .h files?
To build the libraries, you unpacked the gz file, and ran make, didn't you? Or you simply renamed wireless.22.h? Anyways, before you runndk-build, you have a wireless.h file in the package directory. Add the following two lines to the end of this file:
#undef IW_EV_LCP_PK_LEN
#undef IW_EV_POINT_PK_LEN
And remove the iwlib.h from the LOCAL_SRC_FILES of the Android.mk. #Gabe is right, header files should not be compiled separately. In iwlist.c you will find line 14:
#include "iwlib.h"
You normally don't compile header files. You include them in a .c or .cpp file that you do compile. But you wouldn't pass them into the compiler as a source file.
Related
I just updated my NDK to the latest r11c and got this issue while compiling the PCH
clang++: error: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
I have specified my pre-compiled header file via LOCAL_PCH variable and the make script was going to compile it into a .pch file. But it seems clang denied this compile because of the suffix of this file is .h
How can I fix my Android.mk file to the PCH works with the r11c NDK?
Well, I just change the suffix of my precompiled header files from .h to .hpp and this issue is solved.
I'm trying to compile to android environment. And because of that I get the following error:
error: openssl/aes.h: No such file or directory
I find some solution in stack but, I don't get how to end the process to be able to compile.
I already compiled one version of openssl were should I add the libs? or how can I generate the *.a?
Do you know how can I add this library to the arm-linux-androideabi-g++ that I need to run to be able to pass this problem?
[1] Get openssl library which has aes.h file in its include folder.
[2] If you have compiled openssl library in your lib folder then add to -lssl or -lopenssl to your command line.
Here you can find openssl includes: openssl
Download this includes and put them in some folder in your project, i.e. project_dir/module_dir/jni/openssl-includes.
Then you need set a LOCAL_C_INCLUDES variable in your Android.mk (which also is in jni folder:
LOCAL_C_INCLUDES += ./openssl-includes
After that, you can include files in openssl-includes folder directly by name, i.e.:
#include <aes.h>
If you need an *.a file as output, you should include BUILD_STATIC_LIBRARY in Android.mk, if you need a *.so lib, include BUILD_SHARED_LIBRARY.
now, i have a question: first of all i already get the ndk standalone tool chain ---arm-linux-androideabi-g++ sucessful; now i have to write a commandline c++ program which will use libcurl to do http requests, i can successful compile it on my mac( which has the libcurl default? ) use g++, but when i use the arm-linux-androideabi-g++ to compile it, it produce following error:
arm-linux-androideabi-g++ -std=c++11 -lcurl upload.cpp -o upload
upload.cpp:12:23: fatal error: curl/curl.h: no such file or directory
compilation terminated
i have a libcurl(include files and .a lib file) which can used in android, so howto configure the arm-linux-androideabi-g++ so that it can compile it successfully? thanks advance
I guess you include your header like
#include <curl/curl.h>
if you do that, arm-linux-androideabi-g++ searches header file in some specific location. and if arm-linux-androideabi-g++ does not point same directory with g++, headers can not be found. try to copy just header files of curl to your project, jni/curl folder, and use " instead of <
#include "curl/curl.h"
if you have right .a file, functions in header files will be pointed to lib file successfully.
I have namespace error building with ndk-build for native code in my Android app. The error sample is
C:/adt-bundle-windows-x86/ndk/sources/cxx-stl/gnu-libstdc++/4.6/include/bits
/allocator.h:54:1: error: unknown type name 'namespace'
C:/adt-bundle-windows-x86/ndk/sources/cxx-stl/gnu-libstdc++/4.6/include/bits
/allocator.h:55:1: error: expected ',' or ';' before '{' token
For OpenCV settings, my Application.mk file is
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi
APP_PLATFORM := android-10
That means I am using gnu-libstdc++ in compiling the native code.
My jni.c has c extension. That is I receive from my third party and they prefer in .c extension as if they have to change to .cpp extension, they have to change a lot in their other libraries.
So far is OK, I did all project settings for OpenCV for native development and if I do ndk-build, I can make .so libraries.
The problem of those namespace error happened when I include OpenCV's header file #include <opencv2/contrib/detection_based_tracker.hpp> into jni.c and I got a lot of name space error. If I include that #include <opencv2/contrib/detection_based_tracker.hpp> into cpp file, no error.
My questions are
(1)Is the error is because of using .hpp file in .c file?
(2)If I have no choice and have to use that .c file, is there way around to remove that error?
Thanks
My assumption would be that the file is compiled as a "C" file instead of a "C++" file because of the extension ".c". That means you cannot use any "C++" Code in your jni.c, wike classes or namespaces. These are obviously used however in your file "detection_based_tracker.hpp" that you are using.
So the problem is not that you include a file named ".hpp", but that this file contains "C++" code wich the "C" compiler cannot handle.
One solution to this problem is to only use the "C" functions in opencv (for example "opencv2/imgproc/imgproc_c.h" instead of "opencv2/imgproc/imgproc.hpp"). However, your function "detection_based_tracker.hpp" might not have a "C" version, as far as I can see.
The other option is to add a second file "function.cpp" with the "C++" functions that use opencv. The functions from "function.cpp" can be declared in a file "functions.h" and included in your "jni.c", so you can still use opencv c++ functions. Be careful to only use C style functions then, though (no classes, namespaces, ...) in your "function.h" file, otherwise you will have the same problems as before.
Over the last few days I've been having a difficult time trying to build avahi into a static or shared library for use with an existing Android NDK project.
We have a few games in the App and Play stores and my task is to get multiplayer working in the Android versions.
Specifically the task involves replacing the Bonjour component so that these games can connect to each other via zeroconf.
Research seemed to indicate that avahi is the lib that we're looking for, but at this point I'm open to anything that will work!
I'm hoping that someone here can either help me get avahi compiling or suggest another more appropriate (and easier to install) lib.
Project uses android-ndk-r8b and is being built on OSX 10.7.4 using command line (not eclipse)
Got the latest Avahi source from here:
http://www.linuxfromscratch.org/blfs/view/svn/basicnet/avahi.html
homebrewed all the necessary libs to get ./configure to run without errors.
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-static --disable-mono --disable-monodoc --disable-gdbm --disable-libdaemon --disable-nls --disable-gtk --disable-gtk3 --disable-python --disable-qt3 --disable-qt4 --enable-core-docs --with-distro=none
./configure runs with no apparent red flags.
make results in this compile error:
socket.c: In function 'ipv6_pktinfo':
socket.c:271: warning: unused variable 'yes' [-Wunused-variable]
socket.c:270: warning: unused parameter 'fd' [-Wunused-parameter]
socket.c: In function 'avahi_send_dns_packet_ipv6':
socket.c:609: error: 'IPV6_PKTINFO' undeclared (first use in this function)
socket.c:609: error: (Each undeclared identifier is reported only once
socket.c:609: error: for each function it appears in.)
socket.c: In function 'avahi_recv_dns_packet_ipv6':
socket.c:869: error: 'IPV6_HOPLIMIT' undeclared (first use in this function)
socket.c:878: error: 'IPV6_PKTINFO' undeclared (first use in this function)
make[2]: *** [libavahi_core_la-socket.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Figured that it's not building against the android-ndk-r8b libs or finding ipv6.h or something.
Checked my .bash_profile.sh file:
export PATH=/Users/Muy01/Projects/Development/Android/android-sdks/tools/:$PATH
export PATH=/Users/Muy01/Projects/Development/Android/android-sdks/platform-tools/:$PATH
export PATH=/Users/Muy01/Projects/Development/Android/android-ndk-r8b/:$PATH
added --host=arm-linux-androideabi to the ./configure arguments list
resulting in this error:
checking host system type... Invalid configuration `arm-linux-androideabi': system `androideabi' not recognized
Couldn't figure out how to get a list of available host system types so changed direction and decided to try and build the static lib via Android.mk file.
Found this post on creating an appropriate Android.mk file:
can't compile avahi on android
Realized that I don't have Android.mk files within all the subdirectories.
Researched, downloaded, built, Androgenizer to try and convert all the Makefile.am files into Android.mk files.
http://cgit.collabora.com/git/user/derek/androgenizer.git/
Couldn't figure out or find info on how to do that though =/
Decided to try and create my own Android.mk file:
LOCAL_PATH := $(call my-dir)
ROOT_LOCAL_PATH :=$(call my-dir)
#Build avahi into a static lib
include $(CLEAR_VARS)
AVAHI_TOP := $(ROOT_LOCAL_PATH)/../avahi-0.6.31
MY_SOURCES := $(wildcard $(AVAHI_TOP)/avahi-core/*.c*)
MY_SOURCES += $(wildcard $(AVAHI_TOP)/avahi-common/*.c*)
LOCAL_C_INCLUDES := $(AVAHI_TOP)
LOCAL_SRC_FILES := $(MY_SOURCES:$(LOCAL_PATH)%=%)
LOCAL_MODULE := avahi
include $(BUILD_STATIC_LIBRARY)
Results in compile time errors for avahi-core/iface-linux.c:33:0:
/avahi-0.6.31/avahi-core/iface-linux.h:27:8: Redefinition of 'struct AvahiInterfaceMonitorOSDep'
/avahi-0.6.31/avahi-core/iface.h:46:16: Originally defined here
/avahi-0.6.31/avahi-core/iface-linux.h:33:9: Redeclaration of enumerator 'LIST_IFACE'
/avahi-0.6.31/avahi-core/iface.h:52:9: Previous definition of 'LIST_IFACE' was here
/avahi-0.6.31/avahi-core/iface-linux.h:34:9: Redeclaration of enumerator 'LIST_ADDR'
/avahi-0.6.31/avahi-core/iface.h:53:9: Previous definition of 'LIST_ADDR' was here
/avahi-0.6.31/avahi-core/iface-linux.h:35:9: Redeclaration of enumerator 'LIST_DONE'
/avahi-0.6.31/avahi-core/iface.h:54:9: Previous definition of 'LIST_DONE' was here
/jni//../avahi-0.6.31/avahi-core/iface-linux.c: In function 'netlink_callback':
And now I'm pretty much stuck.
I tried #if 0'ing out the iface-linux.c and h files resulting in a cascading slew of other errors, so prob a bad idea.
Thinking that it may be something I've done wrong with the ./configure command?
Perhaps an issue with my Android.mk file?
I figure this must be something that quite a few developers are dealing with so I'm probably missing something because I can't seem to find any good information via google.
Any help would be much appreciated!
I've sent this out to the avhi mailing list as well, if I get a response there I will post here for posterity.
Thanks,
Chris
I'll follow up here with the solution that worked for me.
My solution was to use JMDNS instead of Avahi.
There's not much traffic on the Avahi mailing list.
JMDNS has working examples available.
JMDNS took me about 4 hours to set up within my NDK environment and about a day to work out some "kinks."
tar avahi-0.6.31
patch -p1 < 0001-Add-Android-support.patch
patch -p1 < 0002-Add-uninstalled.pc.in-files.patch
cd avahi-0.6.31
./configure --sysconfdir=/etc --localstatedir=/var
make
cd the subdirectories: make Android.mk
then, you will see Android.mk in all the subdirectories.
ndk-build V=1 NDK_LOG=2 APP_ABI="armeabi armeabi-v7a"