2

CMake can not determine linker language for target: CydiaSubstrate … is the error I am getting. I really don't understand what I am doing wrong nor can I find anything related to adding headers through cmake. Please refer to the code below:

# 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} )
Chivorn
  • 2,203
  • 2
  • 21
  • 37

2 Answers2

0

You can try with this link which already closed in android-ndk sample or this link by Halim Qarroum in other related post.

Hope it can help you.

Chivorn
  • 2,203
  • 2
  • 21
  • 37
0

you code is trying to build 2 libraries: platinmods and CydiaSubstrate. But if your intension is just to let CydiaSubstrate.h used by platinmods.cpp, your code is not doing what you want. Guessing you want later indeed,

  • In source code, do #include "CydiaSubstrate.h", and copy your CydiaSubstrate.h into the same directory as platinmods.cpp
  • Only leave platinmod related code inside build.gradle, delete all CydiaSubstrate related lines
  • If your header file is not in the same folder as your source file, use CMake's target_include_directories() like this
  • If you are having source code backing up that header file, you need to add that source file into compile too ( same as platinmods.cpp )
  • do open CydiaSubstrate.h to see what macro is needed to be defined to use it, that helps.

then do a build->clean, and build ->build apk to see what the problems left ( and fix them ).

Gerry
  • 1,223
  • 9
  • 17