我正在尝试构建一个我收到的也使用C ++代码的Android项目。我通过SDK-Tools Manage安装了NDK,但每次我尝试编译时都会收到以下错误消息:
What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
Error while executing 'D:\Users\Axel\AppData\Local\Android\sdk\cmake\3.6.3155560\bin\cmake.exe' with arguments {--build D:\2016_Demo_Moeller\FloorplanDetector\Quellcode\PointCloudCatcher\app\.externalNativeBuild\cmake\debug\armeabi-v7a --target tango_gl}
[1/26] Building CXX object /tmp/tango_gl/CMakeFiles/tango_gl.dir/drawable_object.cc.o
[2/26] Building CXX object /tmp/tango_gl/CMakeFiles/tango_gl.dir/band.cc.o
[3/26] Building CXX object /tmp/tango_gl/CMakeFiles/tango_gl.dir/frustum.cc.o
[4/26] Building CXX object /tmp/tango_gl/CMakeFiles/tango_gl.dir/gesture_camera.cc.o
[5/26] Building CXX object /tmp/tango_gl/CMakeFiles/tango_gl.dir/goal_marker.cc.o
[6/26] Building CXX object /tmp/tango_gl/CMakeFiles/tango_gl.dir/circle.cc.o
FAILED: D:\Users\Axel\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe -target armv7-none-linux-androideabi -gcc-toolchain D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 --sysroot=/usr/lib -Dtango_gl_EXPORTS -ID:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/include -ID:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/../third_party/glm -ID:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/../third_party/libpng/include -isystem D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -std=gnu++11 -frtti -fexceptions -Wall -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info -fPIC -MD -MT /tmp/tango_gl/CMakeFiles/tango_gl.dir/drawable_object.cc.o -MF \tmp\tango_gl\CMakeFiles\tango_gl.dir\drawable_object.cc.o.d -o /tmp/tango_gl/CMakeFiles/tango_gl.dir/drawable_object.cc.o -c D:\2016_Demo_Moeller\FloorplanDetector\Quellcode\PointCloudCatcher\ext_libs\tango_gl\drawable_object.cc
In file included from D:\2016_Demo_Moeller\FloorplanDetector\Quellcode\PointCloudCatcher\ext_libs\tango_gl\drawable_object.cc:17:
In file included from D:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/include\tango-gl/drawable_object.h:23:
In file included from D:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/include\tango-gl/transform.h:20:
In file included from D:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/../third_party/glm\glm/glm.hpp:78:
In file included from D:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/../third_party/glm\glm/detail/_fixes.hpp:29:
D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include\cmath:44:10: fatal error: 'math.h' file not found
#include <math.h>
^
1 error generated.
我对NDK不太熟悉,但我还没有找到解决问题的方法。我尝试在Application.mk中更改APP_STL,但这并没有改变任何内容。
编辑:
由于Project使用CMake,我想改变Application.mk确实没有任何帮助。以下是主要的CMakeLists.txt:
#
# Main CMakeLists.txt
#
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
#set(lib_src_DIR ${CMAKE_SOURCE_DIR}/../../../../libsrc)
set(ext_lib_src_DIR ${CMAKE_SOURCE_DIR}/../../../../ext_libs)
set(lib_build_DIR $ENV{HOME}/tmp)
file(MAKE_DIRECTORY ${lib_build_DIR})
#set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../distribution)
set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../app/src/main/libs)
set(CMAKE_SYSROOT /usr/lib)
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/../../../build/intermediates/cmake/debug/obj)
#set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--allow-multiple-definition -L${CMAKE_SYSROOT}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -frtti -fexceptions -Wall")
###########################
### ADD SUBDIRECTORIES ###
###########################
set(build_libs TRUE)
if(build_libs)
add_subdirectory(${ext_lib_src_DIR}/dlib_lib
${lib_build_DIR}/dlib_lib)
add_subdirectory(${ext_lib_src_DIR}/3dkht_toolbox
${lib_build_DIR}/3dkht_toolbox)
add_subdirectory(${ext_lib_src_DIR}/third_party
${lib_build_DIR}/libpng)
add_subdirectory(${ext_lib_src_DIR}/tango_gl
${lib_build_DIR}/tango_gl)
endif(build_libs)
###########################
### ADD LIBRARIES ###
###########################
if(!build_libs)
add_library(3dkht SHARED IMPORTED )
set_target_properties(3dkht PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/${ANDROID_ABI}/lib3dkht.so)
add_library(tango_gl SHARED IMPORTED )
set_target_properties(tango_gl PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/${ANDROID_ABI}/libtango_gl.so)
endif(!build_libs)
###########################
### INCLUDES ###
###########################
include_directories(../cpp
${ext_lib_src_DIR}/3dkht_toolbox/Application
${ext_lib_src_DIR}/3dkht_toolbox/SwissArmyKnife
${ext_lib_src_DIR}/dlib_lib
${ext_lib_src_DIR}/tango_gl/include
${ext_lib_src_DIR}/third_party/glm
${ext_lib_src_DIR}/RapidJSON/include
#${ext_lib_src_DIR}/third_party/libpng/include
)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
file(GLOB SOURCES_MAIN "../cpp/*.cpp")
#file(GLOB SOURCES_MAIN "JNIinterface.cpp" "../cpp/*.cpp")
add_library(pointcloudcatcher SHARED ${SOURCES_MAIN})
target_link_libraries(pointcloudcatcher log android EGL GLESv2 3dkht tango_gl)
它不仅可以找到math.h而且还可以找到stdlib.h,并出现以下错误:
FAILED: D:\Users\Axel\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe -target aarch64-none-linux-android -gcc-toolchain D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64 --sysroot=/usr/lib -Dtango_gl_EXPORTS -ID:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/include -ID:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/../third_party/glm -ID:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/../third_party/libpng/include -isystem D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include -isystem D:/Users/Axel/AppData/Local/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -std=c++11 -std=c++11 -frtti -fexceptions -Wall -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info -fPIC -MD -MT /tmp/tango_gl/CMakeFiles/tango_gl.dir/band.cc.o -MF \tmp\tango_gl\CMakeFiles\tango_gl.dir\band.cc.o.d -o /tmp/tango_gl/CMakeFiles/tango_gl.dir/band.cc.o -c D:\2016_Demo_Moeller\FloorplanDetector\Quellcode\PointCloudCatcher\ext_libs\tango_gl\band.cc
In file included from D:\2016_Demo_Moeller\FloorplanDetector\Quellcode\PointCloudCatcher\ext_libs\tango_gl\band.cc:17:
D:/2016_Demo_Moeller/FloorplanDetector/Quellcode/PointCloudCatcher/ext_libs/tango_gl/include\tango-gl/band.h:20:10: fatal error: 'stdlib.h' file not found
#include <stdlib.h>
^
1 error generated.