android - Android Studio Cmake 无法确定目标的链接器语言
问题描述
我尝试将我的根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 )
解决方案
如果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
.
推荐阅读
- matlab - matlab:内存不足,可召开会议的个人电脑
- getopts - korn 脚本选项未正确找到 getopts
- stored-procedures - 从 Talend 中的 tDBrow 调用 Snowflake 存储过程时出错
- apache-spark - Spark 使用的理想表结构是什么(高与宽)?
- javascript - 在同一端点 API 上处理 Express Sever 的多个并发请求
- android - Android - 有没有办法通过 BLE 与连接的外围设备无缝共享 Wi-Fi 连接?
- bash - 使用 dnf 通过 bash 脚本安装多个包
- laravel - 如何使用 @can 检查 laravel 门中的两个权限?
- arrays - 谷歌脚本 - 用谷歌表格的值填充谷歌表单 multipleChoiceItem 和 pageBreak
- angular - 使用 ionic 生成多个 PDF