Skip to content

Commit f4e4dff

Browse files
committed
将已经存在的/MD、/MDd替换为/MT、/MTd
java.lang.UnsatisfiedLinkError Can't find dependent libraries,
1 parent dac4007 commit f4e4dff

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

callc/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
cmake_minimum_required(VERSION 3.4.1)
2+
project(CppCallJni)
3+
4+
if (MSVC)
5+
set(CompilerFlags
6+
CMAKE_CXX_FLAGS
7+
CMAKE_CXX_FLAGS_DEBUG
8+
CMAKE_CXX_FLAGS_RELEASE
9+
CMAKE_C_FLAGS
10+
CMAKE_C_FLAGS_DEBUG
11+
CMAKE_C_FLAGS_RELEASE
12+
)
13+
foreach(CompilerFlag ${CompilerFlags})
14+
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
15+
endforeach()
16+
endif(MSVC)
17+
218
# close openssl
319
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDYZ_DBG")
420
set(JAVA_HOME "$ENV{JAVA_HOME}")

callc/build.bat

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set JAVA_HOME=D:\Program Files\Java\jdk1.8.0_60
1+
set JAVA_HOME=D:\Program Files\Java\jdk-12.0.2
22
set PATH=%PATH%;%JAVA_HOME%\bin;
33
set PATH=%PATH%;E:\Android\sdk\ndk-bundle\android-ndk-r20;D:\Android\ndk\android-ndk-r19c
44
javac -encoding utf-8 -d . callc.java
@@ -7,15 +7,20 @@ rem javah -jni com.durongze.jni.CallC
77
javac -encoding utf-8 -h . callc.java
88

99
rem ndk-build NDK_PROJECT_PATH=. NDK_APPLICATION_MK=Application.mk APP_BUILD_SCRIPT=Android.mk
10-
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
10+
rem call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
11+
call "E:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
1112
mkdir dyzbuild
1213
pushd dyzbuild
13-
cmake -G "Visual Studio 14 2015 Win64" ..
14+
rem cmake -G "Visual Studio 14 2015 Win64" ..
15+
rem Win32 x64
16+
del * /s /q
17+
cmake -G "Visual Studio 16 2019" -A x64 ..
1418
msbuild CLibrary.vcxproj
1519
popd
1620

1721
rem del "%JAVA_HOME%\bin\CLibrary.dll"
1822
for /f %%i in ('dir /s /b "*.dll"') do (copy %%i .\)
23+
del "%JAVA_HOME%\bin\libCLibrary.dll"
1924
copy ".\CLibrary.dll" "%JAVA_HOME%\bin\CLibrary.dll"
2025
java com.durongze.jni.CallC
2126
pause

0 commit comments

Comments
 (0)