windows 10使用javacpp
MSYS2:
下载
更新镜像
C:\msys64\etc\pacman.d
mirrorlist.mingw32 第一行增加 Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686
mirrorlist.mingw64 第一行增加 Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64
mirrorlist.msys 第一行增加 Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch/
=================================
安装最新的jdk
Start msys2 console and run:pacman -Sy pacman
• close msys2 and start again to run:pacman -Syu
• close msys2 and start again to run:pacman -Su
• Next install some necessary packages (press Enter afterwards to accept the installation of all modules):pacman -S base-devel tar patch make git unzip zip nasm yasm pkg-config
• Now we can install mingwpacman -Su mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-i686-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-i686-gcc-fortran mingw-w64-x86_64-libwinpthread-git mingw-w64-i686-libwinpthread-git
• As of 2018-05-18 there is a problem with the gcc compiler when building openblas (maybe other libs too). Therefore download and store the following packages 1 2 3 in the C:\msys64\var\cache\pacman\pkg\ directory. Afterwards start the msys2 console, move to the directory and install the packages:
//这里其实可能已经下好了
cd \var\cache\pacman\pkg\
pacman -U mingw-w64-x86_64-crt-git-6.0.0.5100.739199f8-1-any.pkg.tar.xz
pacman -U mingw-w64-x86_64-headers-git-6.0.0.5102.2f16a8c7-1-any.pkg.tar.xz
pacman -U mingw-w64-x86_64-tools-git-6.0.0.5079.3b7a42fd-1-any.pkg.tar.xz
• Inside the C:\msys64 edit the new files mingw32.ini and mingw64.ini. Remove the # at line 4 resulting in:MSYS2_PATH_TYPE=inherit
• Install Visual Studio 2015 Community Edition and the Windows 10 SDK
https://www.visualstudio.com/downloads/ https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
//这里我下载的是vs2019,这里windows-10-sdk我没有使用也一样可以编译
• Start the command line tool "VS2015 x64 Native Tools Command Prompt" inside the directory:C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts
//我打开的是vs2019 x64的,一定要从Tools Command Prompt窗口来启动mingw64
• Navigate to the C:\msys64 directory and run mingw64.exe
• Check the path (look for /c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/Tools)echo $PATH
• Check the Visual Studio environment variables (should be 14.0)echo $VisualStudioVersion
• Check the include path (look for the include of the ucrt directory e.g. C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt and the general includes C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE)echo $INCLUDE
//这里vs2019 vc下没有include文件夹,用下方位置代替
• Navigate to a directory where you would like to build the libs. e.g. cd /c/Lang/Java/javacpp/
• There run
git clone https://github.com/bytedeco/javacpp.git
git clone https://github.com/bytedeco/javacpp-presets.git
cd javacpp
mvn clean install
//这里会比较慢,
javacpp-presets项目有200多mb
//这里要通过tag来clone,maven依赖的对应版本
git clone --branch 1.4.4 https://github.com/bytedeco/javacpp-presets.git
• At the end of the process the javacpp library has been installed into your local maven repositoryC:\Users\%USERNAME%\.m2\repository\org\bytedeco\javacpp\
• Now you can build the javacpp-preset default project
cd ..
cd javacpp-presets
mvn clean install -Djavacpp.platform=windows-x86_64 --projects .
• ... and afterwards any other preset you like (e.g openblas)
bash cppbuild.sh -platform windows-x86_64 install ffmpeg
mvn install -Djavacpp.platform=windows-x86_64 -Djavacpp.cppbuild.skip=true --projects ffmpeg
• In case the library needs to be compiled with GPU support use
bash cppbuild.sh -platform windows-x86_64 -extension "-gpu" install ffmpeg
mvn install -Djavacpp.platform=windows-x86_64 -Djavacpp.platform.extension="-gpu" -Djavacpp.cppbuild.skip=true --projects ffmpeg