Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C++ wrapper library as a part of the project
- Loading branch information
Showing
6 changed files
with
54 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cmake_minimum_required(VERSION 3.22.1) # it wants an exact version, so 3.22 isn't precise enough | ||
|
||
project("cpp-wrapper") | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED 1) | ||
|
||
# if you set CMAKE_DEBUG_POSTFIX, then you might need to hardcode the build type to Release, | ||
# otherwise you'll need to add the postfix value to the library name in `System.loadLibrary()` | ||
#set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Filename postfix for libraries under DEBUG configuration") | ||
#set(CMAKE_BUILD_TYPE "Release") | ||
|
||
add_library(${CMAKE_PROJECT_NAME} SHARED) # it probably makes sense to hardcode it to SHARED right away | ||
|
||
target_sources(${CMAKE_PROJECT_NAME} | ||
PRIVATE | ||
wrapper.cpp | ||
) | ||
|
||
# target_link_libraries(${CMAKE_PROJECT_NAME} | ||
# PRIVATE | ||
# # these might not be needed | ||
# #android | ||
# #log | ||
# ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <jni.h> | ||
#include <string> | ||
|
||
extern "C" JNIEXPORT jstring JNICALL | ||
Java_com_example_some_MainActivity_doThingy( | ||
JNIEnv *env, | ||
jobject | ||
) | ||
{ | ||
std::string some = "some string of text from wrapper"; | ||
return env->NewStringUTF(some.c_str()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters