2017-10-05 7 views
0

Quelqu'un peut-il m'expliquer comment lier correctement la bibliothèque externe écrite en C++ dans le projet ndk?Studio Android reliant la bibliothèque externe en C++ dans Windows

J'essaie d'utiliser la bibliothèque SDL comme décrit dans cette vidéo: https://www.youtube.com/watch?v=BSBISI0sCqo&t=306s mais le problème se produit lorsque je tente d'exécuter l'une des commandes dans le terminal:

F:/Programmation/Android/Indie/app/src/main/cpp> C:/Users// AppData/Danijel locales/Android/sdk/NDK faisceau/NDK-build NDK_LIBS_OUT = ../jniLibs

ce résultat appel en erreur :

Android NDK: APP_PLATFORM non défini. Valeur par défaut de la version prise en charge minimum android- 14. Android NDK: votre APP_BUILD_SCRIPT pointe vers un fichier inconnu: F: /Programming/Android/Indie/app/src/main/cpp/jni/Android.mk C:/Users/Danijel/AppData/Local/Android/SDK/ndk-bundle/build //../ build/core/add-appl ication.mk:101: *** Android NDK: Abandonner .... Arrêtez. Donc, je sais que le chemin actuel contient le dossier cpp (que je ne peux pas renommer en jni), pas jni, mais la même chose arrive quand j'essaie de définir le chemin dans Gradle.

folder structure

Android.mk:

LOCAL_PATH := $(call my-dir) 
include $(CLEAR_VARS) 
LOCAL_MODULE := app 
LOCAL_CFLAGS := -Wall -Wextra 
LOCAL_SRC_FILES := BoardManager.cpp GameEnvironment.cpp GameObject.cpp Player.cpp Renderer.cpp ShaderManager.cpp Utility.cpp TextureManager.cpp 
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog 
include $(BUILD_SHARED_LIBRARY) 

Application.mk:

APP_PLATFORM=android-14 
APP_ABI := armeabi-v7a 
APP_STL := gnustl_static 

CMakeLists.txt:

# Sets the minimum version of CMake required to build the native 
# library. You should either keep the default value or only pass a 
# value of 3.4.0 or lower. 

cmake_minimum_required(VERSION 3.4.1) 

# Creates and names a library, sets it as either STATIC 
# or SHARED, and provides the relative paths to its source code. 
# You can define multiple libraries, and CMake builds it for you. 
# Gradle automatically packages shared libraries with your APK. 

if (${ANDROID_PLATFORM_LEVEL} LESS 12) 
    message(FATAL_ERROR "OpenGL 2 is not supported before API level 11 (currently using ${ANDROID_PLATFORM_LEVEL}).") 
    return() 
elseif (${ANDROID_PLATFORM_LEVEL} LESS 18) 
    add_definitions("-DDYNAMIC_ES3") 
    set(OPENGL_LIB GLESv2) 
else() 
    set(OPENGL_LIB GLESv3) 
endif (${ANDROID_PLATFORM_LEVEL} LESS 11) 

include_directories(src/main/cpp/) 

add_library(# Sets the name of the library. 
      native-lib 

      # Sets the library as a shared library. 
      SHARED 

      # Provides a relative path to your source file(s). 
      # Associated headers in the same location as their source 
      # file are automatically included. 
      src/main/cpp/native-lib.cpp 
      src/main/cpp/BoardManager.cpp 
      src/main/cpp/GameEnvironment.cpp 
      src/main/cpp/GameObject.cpp 
      src/main/cpp/Player.cpp 
      src/main/cpp/Renderer.cpp 
      src/main/cpp/ShaderManager.cpp 
      src/main/cpp/Utility.cpp 
      src/main/cpp/TextureManager.cpp) 

# Searches for a specified prebuilt library and stores the path as a 
# variable. Because system libraries are included in the search path by 
# default, you only need to specify the name of the public NDK library 
# you want to add. CMake verifies that the library exists before 
# completing its build. 

find_library(# Sets the name of the path variable. 
       log-lib 

       # Specifies the name of the NDK library that 
       # you want CMake to locate. 
       log) 

# Specifies libraries CMake should link to your target library. You 
# can link multiple libraries, such as libraries you define in the 
# build script, prebuilt third-party libraries, or system libraries. 

target_link_libraries(# Specifies the target library. 
         native-lib 
         ${OPENGL_LIB} 
         EGL 
         # Links the target library to the log library 
         # included in the NDK. 
         ${log-lib}) 

Répondre

0
C:/Users/Danijel/AppData/Local/Android/sdk/ndk-bundle/build//../build/core/add-appl ication.mk:101: *** Android NDK: Aborting... . Stop. 

il ya un espace dans add-appl ication.mk

+0

Eh bien, c'est ce que le terminal a généré. Il y a un moment, j'ai vérifié ce fichier dans le dossier correspondant et son nom ne contient aucun espace. Je ne sais pas pourquoi studio Android pense que Android.mk est situé dans le dossier jni quand il n'existe pas. –