PlotJuggler项目跨平台编译指南

PlotJuggler项目跨平台编译指南

PlotJuggler The Time Series Visualization Tool that you deserve. PlotJuggler 项目地址: https://gitcode.com/gh_mirrors/pl/PlotJuggler

PlotJuggler是一款功能强大的数据可视化工具,支持多种数据格式的实时绘图和分析。本文将详细介绍如何在Linux、macOS和Windows三大主流操作系统上编译PlotJuggler项目。

Linux系统编译

依赖安装

在Ubuntu系统上,需要安装以下依赖包:

sudo apt -y install qtbase5-dev libqt5svg5-dev libqt5websockets5-dev \
      libqt5opengl5-dev libqt5x11extras5-dev libprotoc-dev libzmq3-dev \
      liblz4-dev libzstd-dev

Fedora系统用户则需要使用dnf命令安装:

sudo dnf install qt5-qtbase-devel qt5-qtsvg-devel qt5-websockets-devel \
      qt5-qtopendl-devel qt5-qtx11extras-devel

源码获取与编译

建议创建工作目录并克隆源码:

mkdir -p ~/plotjuggler_ws/src
git clone https://github.com/facontidavide/PlotJuggler.git ~/plotjuggler_ws/src/PlotJuggler
cd ~/plotjuggler_ws

使用CMake进行编译(注意:不支持qmake):

cmake -S src/PlotJuggler -B build/PlotJuggler -DCMAKE_INSTALL_PREFIX=install
cmake --build build/PlotJuggler --config RelWithDebInfo --target install

使用Conan管理依赖(可选)

Conan是一个流行的C++包管理工具,可以简化依赖管理:

conan install src/PlotJuggler --install-folder build/PlotJuggler \
      --build missing -pr:b=default

export CMAKE_TOOLCHAIN=$(pwd)/build/PlotJuggler/conan_toolchain.cmake

cmake -S src/PlotJuggler -B build/PlotJuggler \
      -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN  \
      -DCMAKE_INSTALL_PREFIX=install \
      -DCMAKE_POLICY_DEFAULT_CMP0091=NEW

cmake --build build/PlotJuggler --config RelWithDebInfo --target install

打包为AppImage

AppImage是一种流行的Linux应用程序打包格式:

  1. 下载linuxdeploy工具:
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
chmod +x linuxdeploy*.AppImage
mkdir -p AppDir/usr/bin
  1. 执行打包:
cd src/PlotJuggler;export VERSION=$(git describe --abbrev=0 --tags);cd -
echo $VERSION
cp -v install/bin/* AppDir/usr/bin

./linuxdeploy-x86_64.AppImage --appdir=AppDir \
    -d ./src/PlotJuggler/PlotJuggler.desktop \
    -i ./src/PlotJuggler/plotjuggler.png \
    --plugin qt --output appimage

macOS系统编译

依赖安装

使用Homebrew安装所需依赖:

brew install cmake qt@5 protobuf mosquitto zeromq zstd

如果系统中安装了较新版本的Qt,可能需要临时链接到Qt5:

brew link qt@5 --overwrite
# 编译完成后可执行以下命令恢复原始链接
# brew link qt --overwrite

环境变量配置

将Qt相关路径添加到环境变量中:

echo  'QT_HOME=$(brew --prefix qt@5) \
export CPPFLAGS="-I $QT_HOME/include" \
export PKG_CONFIG_PATH="$QT_HOME/lib/pkgconfig" \
export LDFLAGS="$QT_HOME/lib"' >> $HOME/.zshrc

或者临时在当前终端中设置:

QT_HOME=$(brew --prefix qt@5)
export CPPFLAGS="-I $QT_HOME/include"
export PKG_CONFIG_PATH="$QT_HOME/lib/pkgconfig"
export LDFLAGS="$QT_HOME/lib"

源码获取与编译

git clone https://github.com/facontidavide/PlotJuggler.git ~/plotjuggler_ws/src/PlotJuggler
cd ~/plotjuggler_ws

cmake -S src/PlotJuggler -B build/PlotJuggler -DCMAKE_INSTALL_PREFIX=install -DCMAKE_POLICY_VERSION_MINIMUM=3.5
cmake --build build/PlotJuggler --config RelWithDebInfo --target install

Windows系统编译

准备工作

  1. 安装Qt(建议5.15.x版本)
  2. 安装Git
  3. 确保已安装Visual Studio 2019(随Qt 5.15.x安装)

源码获取

cd \
mkdir plotjuggler_ws
cd plotjuggler_ws
git clone https://github.com/facontidavide/PlotJuggler.git src/PlotJuggler

使用Conan编译

注意:Conan方式不支持Arrow/Parque插件,如需该插件请使用vcpkg方式。

conan install src/PlotJuggler --install-folder build/PlotJuggler ^
      --build=missing -pr:b=default

set CMAKE_TOOLCHAIN=%cd%/build/PlotJuggler/conan_toolchain.cmake

cmake -G "Visual Studio 16" ^
      -S src/PlotJuggler -B build/PlotJuggler ^
      -DCMAKE_TOOLCHAIN_FILE=%CMAKE_TOOLCHAIN%  ^
      -DCMAKE_INSTALL_PREFIX=%cd%/install ^
      -DCMAKE_POLICY_DEFAULT_CMP0091=NEW

cmake --build build/PlotJuggler --config Release --target install

使用vcpkg编译

set CMAKE_TOOLCHAIN=/path/vcpkg/scripts/buildsystems/vcpkg.cmake

cmake -G "Visual Studio 16" ^
      -S src/PlotJuggler -B build/PlotJuggler ^
      -DCMAKE_TOOLCHAIN_FILE=%CMAKE_TOOLCHAIN%  ^
      -DCMAKE_INSTALL_PREFIX=%cd%/install

cmake --build build/PlotJuggler --config Release --target install

创建Windows安装包

xcopy src\PlotJuggler\installer installer\ /Y /S /f /z
xcopy install\bin\*.* installer\io.plotjuggler.application\data /Y /S /f /z

C:\QtPro\5.15.16\msvc2019_64\bin\windeployqt.exe --release installer\io.plotjuggler.application\data\plotjuggler.exe

C:\QtPro\Tools\QtInstallerFramework\4.6\bin\binarycreator.exe --offline-only -c installer\config.xml -p installer  PlotJuggler-Windows-installer.exe

总结

本文详细介绍了PlotJuggler在三大主流操作系统上的编译方法。Linux用户可以选择直接编译或使用Conan管理依赖,还可以打包为AppImage格式;macOS用户需要注意Qt版本问题;Windows用户则可以选择Conan或vcpkg两种方式进行编译。根据实际需求选择合适的编译方式,可以更高效地使用这款强大的数据可视化工具。

PlotJuggler The Time Series Visualization Tool that you deserve. PlotJuggler 项目地址: https://gitcode.com/gh_mirrors/pl/PlotJuggler

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

计姗群

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值