编译KArchive在windows10下

使用QT6和VS2019编译KArchive的简要步骤:

  • 安装 Qt ,我是用源码自己编译的  "F:\qtbuild"
  • 安装CMakefile并配置环境变量
  • 安装Git
  • 下载ECM源码 https://github.com/KDE/extra-cmake-modules.git
  • ---------------------------------------------------------------------------------------------------
  • 进入 extra-cmake-modules 源码目录, 使用 VS Command Prompt x64 命令行提示符: 
F:\extra-cmake-modules-master\build>mkdir build 
F:\extra-cmake-modules-master\build>cd build 
F:\extra-cmake-modules-master\build>cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=F:\ECM; -DCMAKE_PREFIX_PATH=F:\qtbuild

F:\extra-cmake-modules-master\build>nmake

F:\extra-cmake-modules-master\build>nmake  install
  • 下载KArchive源码  git clone kArchive https://github.com/KDE/karchive.git
  • 下载Zlib源码 from http://zlib.net/zlib128-dll.zipicon-default.png?t=N7T8http://zlib.net/zlib128-dll.zip put in path-to-karchive\zlib
F:\zlib-1.2.13\zlib-1.2.13\build>cmake .. -G "NMake Makefiles"  -DCMAKE_BUILD_TYPE=release
F:\zlib-1.2.13\zlib-1.2.13\build>nmake

编译好的zlib.lib库放到F:\karchive\zlib目录

  • 下载源码 bzip2(可选) Download bzip2-1.0.5-lib.zip (GnuWin)Provides native Win32 open source ports and utilitiesicon-default.png?t=N7T8http://gnuwin32.sourceforge.net/downlinks/bzip2-lib-zip.php 放到F:\karchive\bzip2
  • 下载 libLZMA(可选) (需要自行编译), GitHub - kobolabs/liblzmaContribute to kobolabs/liblzma development by creating an account on GitHub.icon-default.png?t=N7T8https://github.com/kobolabs/liblzma) 编译好之后放在F:\karchive\libLZMA目录
  • 进入F:\kArchive目录: mkdir build && cd build && F:\karchive-master\build>cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=F:\karchive_install_dir -DCMAKE_BUILD_TYPE=release -DCMAKE_PREFIX_PATH=F:\karchive_install_dir;F:\qtbuild;..\zlib;..\bzip2;

报错:

-- Could NOT find ECM (missing: ECM_DIR)

F:\karchive-master\build>cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=F:\karchive_install_dir -DCMAKE_BUILD_TYPE=release -DCMAKE_PREFIX_PATH=F:\karchive_install_dir;F:\qtbuild;..\zlib;..\bzip2;

-- The C compiler identification is MSVC 19.29.30147.0
-- The CXX compiler identification is MSVC 19.29.30147.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find ECM (missing: ECM_DIR)
--
 * ECM (required version >= 5.240.0), Extra CMake Modules., 

CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/FeatureSummary.cmake:464 (message):
  feature_summary() Error: REQUIRED package(s) are missing, aborting CMake
  run.
Call Stack (most recent call first):
  CMakeLists.txt:9 (feature_summary)

修改CMakeLists.txt文件中的 : find_package(ECM 5.240.0  NO_MODULE)

改为指定ECM的安装目录:

set(ECM_DIR  "F:\\ECM\\share\\ECM")
find_package(ECM REQUIRED PATHS ${ECM_DIR})

继续cmake,提示找不见QT6的安装目录:

Installing in C:/karchive_install_dir. Run F:/karchive-master/build/prefix.sh to set the environment for KArchive.
-- Could not set up the appstream test. appstreamcli is missing.
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
CMake Error at CMakeLists.txt:25 (find_package):
  Could not find a package configuration file provided by "Qt6Core"
  (requested version 6.4.0) with any of the following names:

    Qt6CoreConfig.cmake
    qt6core-config.cmake

 在cmake命令末尾添加QT6的安装路径:

F:\karchive-master\build>cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=F:\karchive_install_dir -DCMAKE_BUILD_TYPE=release -DCMAKE_PREFIX_PATH=F:\karchive_install_dir;F:\qtbuild;..\zlib;..\bzip2;C:\Qt7Dev\6.4.0\msvc2019_64;
  • 执行  nmake install
  • 编译成功,KF6Archive.dll和KF6Archive.lib安装在 F:\karchive_install_dir目录

你可能感兴趣的:(编译KArchive)