I tried linking my root app/
file to a C++ project, but keep getting this error.
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
I have my CMakeLists.txt
file inside of src/min/cpp
along with the iob.c
file it says it can't find. What am I doing wrong?
This is my 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 )
If CMakeLists.txt
is in src/main/cpp
directory (this is how the AS wizard generates a C++ project), then you should say
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 )
Relative paths to source files are calculated relative to the CMakeLists.txt
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With