Reputation: 2881
I just switched from NDK 15 to the one installed with Android Studio (which is currently 17). But now malloc and friends is not found, even though stdlib.h is included.
I've looked everywhere, but found no solution so far. My base class is in c++, which uses a C library. I think this might be relevant. below is the console output.
In file included from ../../../../../../../hdm-deepmap-sql/dms/hdm-deepmap-sql/include/dms/DeepMapSQL.hpp:13:
In file included from /Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/string:470:
In file included from /Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/string_view:169:
In file included from /Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/__string:56:
In file included from /Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/algorithm:643:
In file included from /Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/memory:644:
In file included from /Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/typeinfo:61:
In file included from /Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/exception:82:
/Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/cstdlib:125:9: error: no member named 'calloc' in the global namespace
using ::calloc;
~~^
/Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/cstdlib:126:9: error: no member named 'free' in the global namespace
using ::free;
~~^
/Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/cstdlib:127:9: error: no member named 'malloc' in the global namespace
using ::malloc;
~~^
/Users/ben/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/cstdlib:128:9: error: no member named 'realloc' in the global namespace
using ::realloc;
~~^
4 errors generated.
ninja: build stopped: subcommand failed.
In addition, this is the CMake file for the library:
cmake_minimum_required(VERSION 3.6)
include(../../toolchain/macros.cmake)
project(hdmsql)
set(HDM_SQL_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dms/hdm-deepmap-sql)
file(GLOB_RECURSE SOURCES
${HDM_SQL_SRC_DIR}/*.c
${HDM_SQL_SRC_DIR}/*.cpp
)
list(REMOVE_ITEM SOURCES ${HDM_SQL_SRC_DIR}/src/treeview.c)
add_library(hdmsql STATIC
${SOURCES}
)
target_link_libraries(hdmsql hdmmaputils)
target_include_directories(hdmsql PUBLIC ${HDM_SQL_SRC_DIR}/include/dms/)
target_include_directories(hdmsql PRIVATE ${HDM_SQL_SRC_DIR}/src/)
#############
configure_file(${HDM_SQL_SRC_DIR}/include/dms/DeepMapSQL.hpp "${CMAKE_CURRENT_BINARY_DIR}/DeepMapSQL.hpp")
configure_file(${HDM_SQL_SRC_DIR}/include/dms/dms.h "${CMAKE_CURRENT_BINARY_DIR}/dms.h")
configure_file(${HDM_SQL_SRC_DIR}/include/dms/geometry.h "${CMAKE_CURRENT_BINARY_DIR}/geometry.h")
configure_file(${HDM_SQL_SRC_DIR}/include/dms/vdbeapi.h "${CMAKE_CURRENT_BINARY_DIR}/vdbeapi.h")
Upvotes: 1
Views: 550
Reputation: 2881
I found a workaround. There was a malloc.h header which wrapped malloc calls for the various targeted platforms. Besides that debatably naming a header malloc.h should be considered bad practice, the issue really seems to be in recent versions of the NDK, because the header is included as a private header in CMake and should not collide with the system malloc.h.
Renaming the header solved the issue.
Upvotes: 1