Android Studio Cmake не может определить язык компоновщика для цели - PullRequest
0 голосов
/ 22 октября 2018

Я пытался связать мой корневой app/ файл с проектом C ++, но продолжаю получать эту ошибку.

CMake Error at CMakeLists.txt:15 (add_library):


    src/main/cpp/iob.c


  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp


  .hxx .in .txx


CMake Error: CMake can not determine linker language for target: iob

У меня есть CMakeLists.txt файл внутри src/min/cpp вместе с iob.cфайл говорит, что не может найти.Что я делаю не так?

Это мой CMakeLists.txt

# Sets the minimum version of CMake required to build your native library.
# This ensures that a certain set of CMake features is available to
# your build.

cmake_minimum_required(VERSION 3.4.1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")

# Specifies a library name, specifies whether the library is STATIC or
# SHARED, and provides relative paths to the source code. You can
# define multiple libraries by adding multiple add.library() commands,
# and CMake builds them for you. When you build your app, Gradle
# automatically packages shared libraries with your APK.

add_library( # Specifies the name of the library.
         iob

         # Sets the library as a shared library.
         SHARED

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

1 Ответ

0 голосов
/ 22 октября 2018

Если CMakeLists.txt находится в каталоге src/main/cpp (именно так мастер AS создает проект C ++), вам следует сказать

add_library( # Specifies the name of the library.
     iob

     # Sets the library as a shared library.
     SHARED

     # Provides a relative path to your source file(s).
     iob.c )

Относительные пути к исходным файлам рассчитываются относительно CMakeLists.txt.

...