安装msys2-x86_64,安装完成后使用pacman包管理工具安装开发包中的必要开发工具:
这里面使用的是pacman管理器-S是同步的缩写,可以当作安装命令使用。
pacman -S mingw-w64-x86_64-make mingw-w64-x86_64-gcc mingw-w64-x86_64-pkg-config mingw-w64-x86_64-meson
pacman -S make camke automake gcc
编译SDL2
tar zxfv SDL2-2.0.12.tar.gz
cd SDL2-2.0.12
./configure
make -j 8
make install
检测一下是否正确安装
cd test
./configure
make -j 8
这句就代表找到OpenGL了,可以支持加速了
checking for OpenGL support... yes
运行测试程序
./testgl2.exe
$ ./testgl2.exe
INFO: Screen BPP : 24
INFO: Swap Interval : 0
INFO: Window Size : 640,480
INFO: Draw Size : 640,480
INFO:
INFO: Vendor : Intel
INFO: Renderer : Intel(R) UHD Graphics
INFO: Version : 4.6.0 - Build 27.20.100.7990
INFO: Extensions : GL_3DFX_texture_compression_FXT1 GL_AMD_depth_clamp_separate
需要有下面这些关键输出
./configure
…………
External libraries:
bzlib lzma sdl2 xlib zlib
iconv schannel
…………
Programs:
ffmpeg ffplay ffprobe
编译安装
make -j 8
make install
测试ffmpeg是否安装成功,我们使用ffplay播放一个mp4文件进行测试:
ffplay.exe ./hongkong.mp4
前面都是为了给scrcpy做铺垫,现在需要先声明一下环境变量:
export JAVA_HOME="C:\Program Files\Java\jdk-14.0.2"
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export ANDROID_SDK_ROOT="C:\Users\king\AppData\Local\Android\Sdk"
export PATH=$PATH:"C:\Users\king\AppData\Local\Android\Sdk\platform-tools"
挨个解释一下,第一行是声明Java_HOME,第二个声明ffmpeg、SDL2库的位置,第三行Android SDK的位置,第四行声明adb。
tar zxf scrcpy-1.16.tar.gz
cd scrcpy-1.16/
./server/scripts/build-wrapper.sh "server" "server/scrcpy-server" "release"
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1s
25 actionable tasks: 1 executed, 24 up-to-date
编译过程中如果没有gradle,会自动下载gradle。
meson x --buildtype release --strip -Db_lto=true -Dprebuilt_server=server/scrcpy-server
ninja.exe -Cx
最后scrcpy.exe在./x/app/scrcpy.exe
位置生成。
king@DESKTOP-2F2HH9Q MINGW64 ~/scrcpy-1.16
$ ./run x
INFO: scrcpy 1.16
* daemon not running; starting now at tcp:5037
* daemon started successfully
x/server/scrcpy-server: 1 file pushed, 0 skipped. 66.6 MB/s (33634 bytes in 0.000s)
[server] INFO: Device: OPPO PCAM00 (Android 10)
INFO: Renderer: direct3d
INFO: Initial texture: 1080x2336