我正在尝试使用android-ndk-r20为Android构建C库。 我正在使用CMake构建我的库。
架构为android-arm64
问题是在编译过程中出现以下错误:
/ home / erez / android-ndk-r20 / toolchains / llvm / prebuilt / linux-x86_64 / sysroot / usr / include / c ++ / v1 / __ locale:382:32: 错误:使用未声明的标识符'_ISspace'
相同的错误适用于所有类型的宏- _ISprint , _IScntrl 等
我试图在Google中查找它,但没有提及此宏,这很奇怪。
当我打开该文件时,我确实看到了这些宏的一些用法。
我尝试查找它,但找不到该宏定义的任何位置。 这让我感到困惑,因为我假设nkd / LLVM将包含所有所需的标头和库,但我在任何地方都找不到该标头。
这是我的CMake命令:
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 = $(日期+%Y-%m-%d)../../rootCmake;使VERBOSE = 1安装;
有人知道我该如何解决吗?
编辑:
根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(基于r346389c的5220042)clang版本8.0.7 (https://android.googlesource.com/toolchain/clang b55f2d4ebfd35bf643d27dbca1bb228957008617) (https://android.googlesource.com/toolchain/llvm 3c393fe7a7e13b0fba4ac75a01aa683d7a5b11cd)(基于LLVM 8.0.7svn) 目标:x86_64-unknown-linux-gnu线程模型:posix
答案 0 :(得分:0)
确保没有定义__GLIBC__
。 Android未使用glibc。
来自相关文件__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;
...
}