我试图在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
对此有何建议?
1条答案
按热度按时间5uzkadbs1#
在我的例子中,我在Github Action上运行构建,预装的Mono用许多不需要的库扰乱了构建。我通过将
-DCMAKE_FIND_FRAMEWORK=NEVER
传递给cmake来修复,如这里所讨论的。