libpng警告:应用程序使用libpng-1.4.12构建,但使用1.6.37 c++ mac运行

ctehm74n  于 2023-01-18  发布在  Mac
关注(0)|答案(1)|浏览(363)

我试图在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'
这是我的CmakeList:

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
对此有何建议?

5uzkadbs

5uzkadbs1#

在我的例子中,我在Github Action上运行构建,预装的Mono用许多不需要的库扰乱了构建。我通过将-DCMAKE_FIND_FRAMEWORK=NEVER传递给cmake来修复,如这里所讨论的。

相关问题