AppVeyor c++cmake PNG包编译错误

AppVeyor c++ cmake PNG package compilation error

本文关键字:编译 错误 c++cmake PNG 包编译 AppVeyor      更新时间:2023-10-16

我正试图通过带有cmake的AppVeyor为windows编译一个跨平台的QT应用程序。

在Linux下,cmake编译得很好,所以CMakeLists.txt应该是有效的。

AppVeyor编译了一个必要的库,它也能工作。但当涉及到项目CMakeLists.txt时,它失败了,并出现以下错误:

-- Could NOT find ZLIB (missing:  ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindPNG.cmake:157 (find_package_handle_standard_args)
CMakeLists.txt:20 (find_package)

CMakeLists.txt中的相应部分是:

find_package(PNG REQUIRED)
[...some other cmake stuff...]
# link required other libraries
include_directories(${PNG_INCLUDE_DIR} ${GSL_INCLUDE_DIRS})
target_link_libraries(projectName ${PNG_LIBRARY} ${GSL_LIBRARIES})

这是当前生成失败:https://ci.appveyor.com/project/zebastian/mandelbulber2

使用过的CMakeLists.txt和appveyor.yml文件可以在项目根目录中找到:https://github.com/zebastian/mandelbulber2

由于FindPNG.cmake存在,似乎只缺少zlib,这似乎有点奇怪。我看到了一些appveyor.yml文件,它们通过下载和编译一些png/zlib源文件夹或使用外部依赖项来规避这个问题,但IMHO这对CI来说应该是一项简单的任务。

还是我错过了什么?

感谢任何帮助。。。

好的,我找到了这个特定问题的解决方案:

在windows中,有一个名为nuget的包管理器来解决这种依赖关系,它在appveyor中也能很好地工作。要安装libpng,我使用了以下命令:

#packages from nuget
- nuget install zlib-msvc14-x64-master -Version 1.2.8.4 -Source https://ci.appveyor.com/nuget/zlib-shallow-x0n34b3pfq1b
- ps: move zlib** deps -force
- move depszlibstatic.lib depszlib.lib
- nuget install libpng-msvc14-x64-master -Version 1.6.18.44 -Source https://ci.appveyor.com/nuget/libpng-7hwq4pmmrc48
- ps: move libpng** deps -force
- move depslibpng16_static.lib depspng.lib

其中ps和move仅用于移动事物。对我来说,这似乎是一个合理的解决方案,可以让一些人免于繁琐的自我编译。

由于窗口占用并与4个字母的杂注以及其他msvc特定的行为发生冲突,编译仍然失败。但这是另一天的话题。。。