Use vcpkg with Qt Creator and include PODOFO into a project

80 Views Asked by At

I want to use the PODOFO package in Qt Creator on Windows 10. I don't know how to include libraries in Qt, so I tried using vcpkg to install PODOFO and include this library in my project.

However, that doesn't work, as it throws these errors:

 -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
[cmake] 
[cmake] CMake Error at C:/Qt/Tools/CMake_64/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
[cmake]   Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
[cmake] Call Stack (most recent call first):
[cmake]   C:/Qt/Tools/CMake_64/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
[cmake]   C:/Qt/Tools/CMake_64/share/cmake-3.27/Modules/FindFreetype.cmake:162 (find_package_handle_standard_args)
[cmake]   CMakeLists.txt:22 (find_package)

My approach was as follows:

I installed vcpkg with:

> git clone https://github.com/microsoft/vcpkg
> .\vcpkg\bootstrap-vcpkg.bat

After that, I activated the vcpkg plugin in Qt Creator, and provided the path to my vcpkg installation.

A quick reboot, and I added the vcpkg.json to my project, from where I installed the PODOFO package via the taskbar, and added the provided code to the CMakeLists.txt file.

find_package(podofo CONFIG REQUIRED)
target_link_libraries(PDFMergerMSVC PRIVATE podofo::podofo)

Then, when I tried to build my project, these errors occurred:

C:\Users\white\OneDrive\Projekte\PDFMergerGitHub\PDFMerger\src\CMakeLists.txt:17: Fehler: Could not find a package configuration file provided by "podofo" with any
of the following names:

  podofoConfig.cmake
  podofo-config.cmake

Add the installation prefix of "podofo" to CMAKE_PREFIX_PATH or set
"podofo_DIR" to a directory containing one of the above files.  If "podofo"
provides a separate development package or SDK, be sure it has been
installed.

After adding these lines to my CMakeLists.txt:

set(CMAKE_TOOLCHAIN_FILE "C:/vcpkg/scripts/buildsystems/vcpkg.cmake")
include("C:/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(VCPKG_TARGET_TRIPLET "x64-windows")
set(podofo_DIR "C:/vcpkg/installed/x64-windows/share/podofo")

It tells me the following:

C:\Users\white\OneDrive\Projekte\PDFMergerGitHub\PDFMerger\src\CMakeLists.txt:22: Fehler: Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)

Call-Stack:
  C:/Users/white/OneDrive/Projekte/PDFMergerGitHub/PDFMerger/src/CMakeLists.txt:22 (find_package)
  C:/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
  C:/vcpkg/installed/x64-windows/share/podofo/podofo-config.cmake:2 (find_dependency)
  C:/Qt/Tools/CMake_64/share/cmake-3.27/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  C:/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
  C:/Qt/Tools/CMake_64/share/cmake-3.27/Modules/FindFreetype.cmake:162 (find_package_handle_standard_args)
  C:/Qt/Tools/CMake_64/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Qt/Tools/CMake_64/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message)
1

There are 1 best solutions below

0
cptn lucky On

You need to copy the podofo library into you source directory. Then you will need to add the following lines to my CMake File:

set(PODOFO_BUILD_LIB_ONLY TRUE CACHE BOOL "" FORCE)
set(PODOFO_BUILD_STATIC TRUE CACHE BOOL "" FORCE)
add_subdirectory(podofo)

Also there seems to be an issue where Qt doesn't save changes to the vcpkg.json, so you need make a change, save that and then again revert the change and save again in order to save it properly.