Reputation: 103
I'm trying to build C library for android using android-ndk-r20. I am using CMake to build my library.
The architecture is android-arm64
The problem is that I get the following errors during compilation:
/home/erez/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__locale:382:32: error: use of undeclared identifier '_ISspace'
Same error goes for all kind of macros - _ISprint, _IScntrl etc.
I have tried to look it up in Google but there is no mention of this macro, which is weird.
When I open this file I do see some use of this macros.
I have tried to look it up but I could not find any place that this macro is defined. It is confusing to me because I assume that the nkd/LLVM will be self contained with all the needed headers and libraries, but I cant find this header anywhere.
This is my CMake command:
cmake -DCMAKE_CXX_FLAGS:STRING="-std=c++11" -DANDROID_NATIVE_API_LEVEL=24 -DTARGET=android -DANDROID_ABI=arm64-v8a -DLIBRARY_OUTPUT_PATH_ROOT=
pwd
/../android_output -DCMAKE_TOOLCHAIN_FILE=pwd
/../../../../../android-ndk-r20/build/cmake/android.toolchain.cmake -DBUILD_DATE=$(date +%Y-%m-%d) ../../rootCmake ; make VERBOSE=1 install ;
Does anyone have any idea how do I solve this?
Edit:
root CMakeLists.txt:
project(Osn)
cmake_minimum_required(VERSION 2.8)
set(TARGET "android" CACHE STRING "Set the target ios mac32/64, linux32/64, android, win32/64")
# Static link the c++ library in case of a gcc compiler.
if (CMAKE_COMPILER_IS_GNUCC)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/gcc_config.cmake)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/darwin.cmake)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux.cmake)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/msvc_config.cmake)
#elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS")
# include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ios-arm.cmake)
endif()
if (${TARGET} MATCHES "android")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/android.cmake)
endif()
add_subdirectory(OsnClient/OsnClient)
#if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "iOS")
add_subdirectory(OsnClientApp/OsnClientApp)
#endif()
srcs CMakelists.txt:
project(ProjectName)
cmake_minimum_required(VERSION 2.8)
set(OSN_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(OSN_INCLUDE ${OSN_ROOT}/../../../include)
set(OSNCLIENT_EXPORTS on)
set(gabro_files ${CMAKE_CURRENT_SOURCE_DIR}/../../../gabro/${TARGET} )
if (${TARGET} MATCHES android)
set(gabro_files ${CMAKE_CURRENT_SOURCE_DIR}/../../../gabro/${TARGET}-${ANDROID_ABI} )
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES Windows)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}
/NODEFAULTLIB:libboost_date_time-vc100-mt-s-1_47.lib
....
....
/VERBOSE:LIB
")
endif()
add_definitions(-DGABRO_WIN32_API_STATIC)
set(src
${OSN_ROOT}/src1.cpp
${OSN_ROOT}/src2.cpp
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${OSN_ROOT}
${gabro_files}/include
${OSN_INCLUDE}
)
if (${TARGET} MATCHES android)
set(log_lib ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/lib )
endif()
link_directories(
${gabro_files}/lib
)
set(link_libs gabro_client_api_static)
if (WIN32)
list(APPEND link_libs gabro_static_external-mt wininet )
elseif (${CMAKE_SYSTEM_NAME} MATCHES Darwin)
list(APPEND link_libs gabro_static_external pthread z dl)
elseif (${TARGET} MATCHES android)
list(APPEND link_libs gabro_static_external libOsnClient.so log)
else()
list(APPEND link_libs gabro_static_external pthread dl rt)
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "ios")
add_library(${PROJECT_NAME} STATIC ${src})
else()
add_library(${PROJECT_NAME} SHARED ${src})
endif()
target_link_libraries(${PROJECT_NAME} ${link_libs} )
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
clang++ --version:
Android (5220042 based on r346389c) clang version 8.0.7 (https://android.googlesource.com/toolchain/clang b55f2d4ebfd35bf643d27dbca1bb228957008617) (https://android.googlesource.com/toolchain/llvm 3c393fe7a7e13b0fba4ac75a01aa683d7a5b11cd) (based on LLVM 8.0.7svn) Target: x86_64-unknown-linux-gnu Thread model: posix
Upvotes: 3
Views: 1194
Reputation: 1947
Make sure you don't have __GLIBC__
defined. Android is not using glibc.
From the file in question __locale
:
class _LIBCPP_TYPE_VIS ctype_base
{
public:
#if defined(__GLIBC__) // <-- Here's the problem
typedef unsigned short mask;
static const mask space = _ISspace;
static const mask print = _ISprint;
static const mask cntrl = _IScntrl;
static const mask upper = _ISupper;
...
}
Upvotes: 0