NDK xlocale.h exception - android

Trying to load live555 library but having following error when I do ndk-build
Compile++ thumb : live555 <= Locale.cpp
In file included from jni/live555/Locale.cpp:22:0:
/Volumes/Projects/Ayaz_Projects/streamer/./jni/live555/include/Locale.hh:47:123: fatal error: xlocale.h: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi/objs/live555/Locale.o] Error 1
xlocale.h is nowhere in the live555 code
What should I do?

The include file has the following:
#ifndef LOCALE_NOT_USED
#include <locale.h>
#ifndef XLOCALE_NOT_USED
#include <xlocale.h> // because, on some systems, <locale.h> doesn't include <xlocale.h>; this makes sure that we get both
#endif
#endif
So you should be able to add -DXLOCALE_NOT_USED to your Android.mk to avoid this.

I got here seearching for xlocale.h not found (unrelated to android development). My solution was https://serverfault.com/a/791822/394721

Related

Implementing baresip NDK library causes lack of *.so file

I want to implement baresip lib into my Android project using NDK.
I've found up-to-date "bare bones" demo-project in HERE. As in readme I've created some native libs from another repo and placed in "distribution" folder. Project is compiling, installing, working fine. Comparing to Android native sip implementation this lib is just awesome, use it, forget about permission.USE_SIP, its rubish.
Now I want to import baresip into my project, but without Java/Kotlin files, planning to build own. So my steps:
Added externalNativeBuild entries to build.gradle
Copied cpp and distribution folders to proper places in my structure
Invalidate cache and restart
And got exception:
Build command failed.
Error while executing process C:\Android\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\Android\projects\MyApplication\app.cxx\cmake\debug\armeabi-v7a --target baresip}
[1/2] Building C object CMakeFiles/baresip.dir/baresip.c.o
[2/2] Linking C shared library C:\Android\projects\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi-v7a\libbaresip.so
FAILED: cmd.exe /C "..."
next some duplicated lines like:
src/video.c:331: error: undefined reference to 'atof'
src/main/main.c:944: error: undefined reference to 'signal'
src/main/main.c:775: error: undefined reference to '__FD_ISSET_chk'
src/main/main.c:690: error: undefined reference to '__FD_SET_chk'
C:/Android/projects/MyApplication/app/src/main/cpp/../../../../distribution/openssl/lib/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigfillset'
and ends with
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
note app/src/main/cpp/../../../../distribution/ files path, as declared in CMakeLists:
set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../distribution)
For me it looks like not-visible files for compiler, but when I add/remove some/any ../ error changes to clearly suggesting wrong path. besides same path and hierarchy is in sample project
I've tried to strip out baresip.c file, but its crashing with just logging OnLoad call...
#include <string.h>
#include <pthread.h>
#include <jni.h>
#include <android/log.h>
#include <stdlib.h>
#include <re.h>
#include <baresip.h>
#define LOGD(...) \
if (log_level_get() < LEVEL_INFO) ((void)__android_log_print(ANDROID_LOG_DEBUG, "Baresip Lib", __VA_ARGS__))
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
LOGD("at JNI_OnLoad\n");
return JNI_VERSION_1_6;
}
crash still occurs, but when I comment out if (log_level_get() < LEVEL_INFO) call my project is building and install just fine... log_level_get() comes from baresip.h, which is #included, libbaresip.a files (per abi) present, so why is libbaresip.so missing, why it isn't generating? what lines are present in sample project which makes it to build and work?
(yep, I'm pretty weak in native, lost some support from colleagues due to coronavirus...)
turns out it was a bit hidden, but nothing tough... target/compile SDK version should be at least 21 for this lib, I had 19, thats why ndk wasn't compiling properly...

Cross Compiling KConfig is not working

I'm trying to compile kconfig, which supposedly works on android, for android but am faced with the following
In file included from /home/dashed/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_algo.h:59:0,
from /home/dashed/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/algorithm:62,
from /home/dashed/android-qt/include/QtCore/qglobal.h:109,
from /home/dashed/android-qt/include/QtCore/QtGlobal:1,
from /home/dashed/Documents/kconfig/src/core/kconfigbase.h:29,
from /home/dashed/Documents/kconfig/src/core/kconfig.h:27,
from /home/dashed/Documents/kconfig/src/core/kconfig.cpp:23:
/home/dashed/android-ndk-r10e/sources/cxx-stl/gnu-
libstdc++/4.9/include/cstdlib:72:20: fatal error: stdlib.h: No such file or directory
#include <stdlib.h>
^
I generated the makefile with :
cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake -DECM_ADDITIONAL_FIND_ROOT_PATH=/home/dashed/android-qt -DCMAKE_INSTALL_PREFIX=/home/dashed/android-kf5 ..
what can I do to compile it successfully ?
I sorta 'solved' this by updating my ndk. I was using r10e to compile qt but using r17b is successful.

How to fix fatal error as a result of adding a header file

I am trying to compile a device driver for my target platform which is Snapdragon msm8974. I added some more code to an already tested module; and added more header files. One of the header files was not in my include directory, so I searched in my environment and found a number of options so I chose
~/android/android-ndk-r10d/platforms/android-19/arch-arm/usr/include/stdint.h
But I keep getting the following error, and do not know how to go about fixing it. Any advice on what I can do differently is greatly appreciated. Here is the error:
include/linux/stdint.h:32:24: fatal error: sys/_types.h: No such file or directory
compilation terminated.
Here is all my include statements in the file:
#include <inttypes.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <stdlib.h>

Issue porting Cocos2d-x to Android

I've written a basic game using Cocos2D-x. It works fine on the iPhone. Now I'm trying to port it to Android. When I run the script, it gives me the following error:
jni/../../Classes/MemoryModeLayer.cpp: In member function 'void MemoryModeLayer::startNewGame()':
jni/../../Classes/MemoryModeLayer.cpp:109:25: error: 'time' is not a member of 'std'
jni/../../Classes/MemoryModeLayer.cpp:109:25: note: suggested alternative:
/Users/abc/android-ndk-r9d/platforms/android-8/arch-arm/usr/include/time.h:40:17: note: 'time'
jni/../../Classes/MemoryModeLayer.cpp:111:5: error: 'random_shuffle' is not a member of 'std'
jni/../../Classes/MemoryModeLayer.cpp:112:5: error: 'random_shuffle' is not a member of 'std'
make: *** [obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/MemoryModeLayer.o] Error 1
make: Leaving directory `/Users/anil/cocos2d-x-2.2.3/projects/Game/proj.android'
In MemoryModeLayer.cpp I have the following:
std::srand(unsigned(std::time(0)));
std::random_shuffle(_xCod, _xCod + _numberOfRows);
std::random_shuffle(_yCod, _yCod + _numberOfColumns);
I've included the following headers as well:
#include <string>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <iomanip>
Also added using namespace std in the header file. Is there anything else that I should do?
you need to #include <random>
There was a problem with the Application.mk file. Had to change the STL library lookup like so:
Add APP_STL := stlport_static to the Application.mk file. It may already have APP_STL := gnustl_static.
Following blog post was very helpful!
http://blog.codetactics.com/2013/06/05/porting-a-cocos2d-x-ios-game-to-android/

Android - NDK strange error

I start getting funny errors with NDK with fairly complex program:
#include <stdio.h>
#include <iostream>
int main( int argc, char **argv ) {
return 0;
}
>call c:\android-ndk-r9\ndk-build.cmd
"Compile++ thumb : test <= test.cpp
In file included from C:/workspace/c++11_test//jni/test.cpp:11:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\iostream:43:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_istream.h:31:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_ostream.h:380:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_ostream.c:26:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_num_put.h:180:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_num_put.c:26:
c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_limits.h:217:48: error: non-type template argument evaluates to -2147483648, which cannot be narrowed to type 'wchar_t'
[-Wc++11-narrowing]
: public _STLP_PRIV _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX, -1, true>
^
c:/android-ndk-r9/platforms/android-14/arch-arm/usr/include\../include/wchar.h:76:22: note: expanded from macro 'WCHAR_MIN'
#define WCHAR_MIN INT_MIN
^
c:/android-ndk-r9/platforms/android-14/arch-arm/usr/include\sys/limits.h:69:18: note: expanded from macro 'INT_MIN'
#define INT_MIN (-0x7fffffff-1) /* min value for an int */
^
1 error generated.
make: * [C:/workspace/c++11_test//obj/local/armeabi/objs/test/test.o] Error 1
It's ndk-r9. 4.8 complie it just fine, only clang stumbles on it.
Do I need to define something to make clang work?
I've tried to Google errors, but got nothing relevant...
Obviously, I can turn it off with -Wno-c++11-narrowing, but I don't want disable narrowing checks.
And it's only shows with stlport_static, there is NO error with gnustl_static
You appear to have enabled C++11, since you are getting this warning.
STLport support for C++11 is not very good. I suspect this is the reason for your woes.
A fix requires changes to STLport, or removing the "-std=c++11" switch from the clang command-line.
IMHO, I would recommend switching to the gnustl (aka. libstdc++), unless there are other reasons that prevent you from doing so (licensing: libstdc++ is GPL3 with some significant exceptions that may or may not be valid for clang - you should determine that for yourself), legacy support, size etc.). I have had very good experiences with that.

Categories

Resources