Msys2 和Git for window工具
阿新 • • 發佈:2021-01-13
技術標籤:構建管理工具
git for window 最方便
安裝Msys2環境
https://www.msys2.org/
按照上面官網提示配置gcc環境
修改源:進入msys64/etc/pacman.d/, 需要修改三個檔案, 都新增在Server列表第一行(不介意速度可省)
##mirrorlist.mingw32
Server = http://mirrors.ustc.edu.cn/msys2/mingw/i686/
##mirrorlist.mingw64
Server = http://mirrors.ustc.edu.cn/msys2/mingw/x86_64/
##mirrorlist.msys
Server = http://mirrors.ustc.edu.cn/msys2/msys/$arch/
1.Update the package database and base packages. Unless your setup file is very recent, it will take two steps. First run pacman -Syu
pacman -Syu
2.Run “MSYS2 MSYS” from Start menu. Update the rest of the base packages with pacman -Su
pacman -Su
3.Now MSYS2 is ready for you. You probably will want to install some tools and the mingw-w64 GCC to start compiling:
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
Enter a selection (default=all): all
##預設安裝全部
4.To start building using the mingw-w64 GCC, close this window and run “MSYS MinGW 64-bit” from Start menu. Now you can call make or gcc to build software for Windows
如下可編譯Java本地方法
cygpath -w $(pwd ) ##路徑轉換
#javah -encoding utf-8 jw.usejni.JniSample
gcc -I"C:\Program Files\Java\jdk-15.0.1\include" -I"C:\Program Files\Java\jdk-15.0.1\include\win32" jw_usejni_JniSample.c -o JniSample.dll