首页 > 解决方案 > libpng 警告:使用 libpng-1.4.12 构建但使用 1.6.37 c++ mac 运行的应用程序

问题描述

我正在尝试在 vscode 中使用 OpenCV c++ 版本读取和显示图像,但我不断收到此错误:

libpng warning: Application built with libpng-1.4.12 but running with 1.6.37 libc++abi: terminating with uncaught exception of type cv::Exception: OpenCV(4.5.3) /Users/aniekan/opencv/opencv-4.5.3/modules/highgui/src/window.cpp:1006: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

这是我的 CmakeLists:

cmake_minimum_required(VERSION 3.0.0)
project(C++ VERSION 0.1.0)

include(CTest)
include(FindPkgConfig)
enable_testing()

pkg_check_modules(LIBPNG libpng16 REQUIRED)
if (NOT LIBPNG_FOUND)
   message(FATAL ERROR "libpng16 development libaries not installed")
endif()

message(PNG_LIBRARIES = "${LIBPNG_LIBRARIES}")

find_package(OpenCV REQUIRED)

include_directories(${OpenCV_INCLUDE_DIRS} ${LIBPNG_INCLUDE_DIRS})
link_directories(${LIBPNG_LIBRARY_DIRS})

add_executable(C++ main.cpp)

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${LIBPNG_LIBRARIES})

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

make 文件构建没有错误并找到所需的但我仍然得到错误。这是构建输出: build_output

关于这个问题有什么建议吗?

标签: c++opencvcmake

解决方案


推荐阅读