Android Studio включает заголовки cpp - PullRequest
0 голосов
/ 20 сентября 2018

CMake не может определить язык компоновщика для цели: CydiaSubstrate… это ошибка, которую я получаю.Я действительно не понимаю, что я делаю неправильно, и не могу найти ничего, связанного с добавлением заголовков через cmake.Пожалуйста, используйте код ниже:

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

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 them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
         platinmods

         # Sets the library as a shared library.
         SHARED

         # Provides a relative path to your source file(s).
         src/main/cpp/platinmods.cpp )

add_library( # Sets the name of the library.
         CydiaSubstrate

         # Sets the library as a shared library.
         SHARED

         # Provides a relative path to your source file(s).
         src/main/cpp/CydiaSubstrate.h )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries 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 this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
                   platinmods

                   # Links the target library to the log library
                   # included in the NDK.
                   ${log-lib} )

target_link_libraries( # Specifies the target library.
                   CydiaSubstrate

                   # Links the target library to the log library
                   # included in the NDK.
                   ${log-lib} )

Ответы [ 2 ]

0 голосов
/ 20 сентября 2018

ваш код пытается собрать 2 библиотеки: platinmods и CydiaSubstrate.Но если вы намерены просто позволить CydiaSubstrate.h использовать platinmods.cpp, ваш код не выполняет то, что вы хотите.Предположим, что вы хотите позже, действительно,

  • В исходном коде выполните #include "CydiaSubstrate.h" и скопируйте свой CydiaSubstrate.h в тот же каталог, что и platinmods.cpp
  • . Оставьте только код, связанный с platinmod, внутриbuild.gradle, удалите все связанные с CydiaSubstrate строки
  • Если ваш заголовочный файл не находится в той же папке, что и исходный файл, используйте CMake target_include_directories (), например this
  • Если у вас есть исходный код для резервного копирования этого заголовочного файла, вам нужно добавить этот исходный файл также в компиляцию (так же, как platinmods.cpp)
  • действительно откройте CydiaSubstrate.h, чтобы увидеть, что это за макроснужно определить, чтобы использовать его, это помогает.

затем выполните build-> clean и build -> build apk, чтобы увидеть, какие проблемы остались (и исправить их).

0 голосов
/ 20 сентября 2018

Вы можете попробовать эту ссылку, которая уже закрыта в android-ndk sample или эту ссылку на Halim Qarroum в другом соответствующем сообщении.

Надеюсь, что сможетпомочь вам.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...