xmake-io / xmake-repo

📦 An official xmake package repository
https://xrepo.xmake.io
Apache License 2.0
692 stars 405 forks source link

opencv: win下使用vcpkg::opencv,vcpkg已经成功安装了,但xmake check不到 #5402

Open KkemChen opened 1 month ago

KkemChen commented 1 month ago

Xmake 版本

2.9.5

操作系统版本和架构

Windows11

描述问题

如题

Building opencv[contrib,core,default-features,freetype]:x64-windows-static@4.8.0#1...
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVConfig.cmake
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVConfig-version.cmake
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVModules.cmake
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVModules-release.cmake
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVModules-debug.cmake
-- Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE
Stored binaries in 1 destinations in 98.2 ms.
Elapsed time to handle opencv:x64-windows-static: 190 ms
opencv:x64-windows-static package ABI: 73d127ca672c832f82cfdcc0b2435ea64df748687fd39a50f9267c3756bd42dc
Total install time: 23 min
opencv provides CMake targets:

  # this is heuristically generated, and may not be correct
  find_package(OpenCV CONFIG REQUIRED)
  # note: 53 additional targets are not displayed.
  target_link_libraries(main PRIVATE opencv_ml opencv_dnn opencv_dpm opencv_hdf)

checking for vcpkg::opencv[contrib,freetype] ... no

error: fetch vcpkg::opencv[contrib,freetype]-latest failed!
  => install vcpkg::opencv[contrib,freetype] latest .. failed
error: install failed!

期待的结果

解决

工程配置

add_rules("mode.debug", "mode.release")
set_policy("package.precompiled", false)

set_languages("c++20")

set_encodings("utf-8")
add_requires("vcpkg::opencv[contrib,freetype]")
target("osd")
    set_kind("binary")
    add_files("src/*.cpp")
    add_packages("opencv")

附加信息和错误日志

-- Using msys root at C:/vcpkg/downloads/tools/msys2/1e74ca60daa10104
-- Installing: C:/vcpkg/packages/opencv4_x64-windows-static/share/opencv4/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 36 s.
Elapsed time to handle opencv4:x64-windows-static: 5.1 min
opencv4:x64-windows-static package ABI: afcef3206334a7fcacb344492f6122ba7d57940c2058ba7eaaa89716565f2e1b
Installing 15/15 opencv[contrib,core,default-features,freetype]:x64-windows-static@4.8.0#1...
Building opencv[contrib,core,default-features,freetype]:x64-windows-static@4.8.0#1...
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVConfig.cmake
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVConfig-version.cmake
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVModules.cmake
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVModules-release.cmake
-- Installing: C:/vcpkg/packages/opencv_x64-windows-static/share/opencv/OpenCVModules-debug.cmake
-- Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE
Stored binaries in 1 destinations in 98.2 ms.
Elapsed time to handle opencv:x64-windows-static: 190 ms
opencv:x64-windows-static package ABI: 73d127ca672c832f82cfdcc0b2435ea64df748687fd39a50f9267c3756bd42dc
Total install time: 23 min
opencv provides CMake targets:

  # this is heuristically generated, and may not be correct
  find_package(OpenCV CONFIG REQUIRED)
  # note: 53 additional targets are not displayed.
  target_link_libraries(main PRIVATE opencv_ml opencv_dnn opencv_dpm opencv_hdf)

checking for vcpkg::opencv[contrib,freetype] ... no

error: fetch vcpkg::opencv[contrib,freetype]-latest failed!
  => install vcpkg::opencv[contrib,freetype] latest .. failed
error: install failed!
Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


Title: opencv: Use vcpkg::opencv under win. vcpkg has been successfully installed, but xmake cannot check.

waruqi commented 1 month ago

add_packages 要跟 add_requires 的包名一致 add_packages("vcpkg::opencv[contrib,freetype]"),否则关联不上。。如果你 add_packages 不想写这么长,那就设置 alias

add_requires("vcpkg::opencv[contrib,freetype]", {alias = "opencv"})
KkemChen commented 1 month ago

add_packages 要跟 add_requires 的包名一致 add_packages("vcpkg::opencv[contrib,freetype]"),否则关联不上。。如果你 add_packages 不想写这么长,那就设置 alias

add_requires("vcpkg::opencv[contrib,freetype]", {alias = "opencv"})

他这里好像都没有到 add_packages的阶段,还在install的时候就寄了

waruqi commented 1 month ago

那就自己调下这里,https://github.com/xmake-io/xmake/blob/dev/xmake/modules/package/manager/vcpkg/find_package.lua

fetch 没找到安装后的包而已。

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


Then adjust it here yourself, https://github.com/xmake-io/xmake/blob/dev/xmake/modules/package/manager/vcpkg/find_package.lua

fetch did not find the installed package.

KkemChen commented 1 month ago

刚尝试调试了一下,发现xmake读取这个 infofile里的内容,但是里面只有这些内容,并没有 include,lib等文件夹。 不知道是不是新版的vcpkg做了改动

x64-windows-static/
x64-windows-static/share/
x64-windows-static/share/opencv/
x64-windows-static/share/opencv/OpenCVConfig-version.cmake
x64-windows-static/share/opencv/OpenCVConfig.cmake
x64-windows-static/share/opencv/OpenCVModules-debug.cmake
x64-windows-static/share/opencv/OpenCVModules-release.cmake
x64-windows-static/share/opencv/OpenCVModules.cmake
x64-windows-static/share/opencv/vcpkg.spdx.json
x64-windows-static/share/opencv/vcpkg_abi_info.txt
KkemChen commented 1 month ago

image

opencv_4.8.0_x64-windows-static.list 里面没有 opencv4_4.8.0_x64-windows-static.list 这个里面倒是有 include,lib这些

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


image

There is no opencv_4.8.0_x64-windows-static.list opencv4_4.8.0_x64-windows-static.list contains include, lib, etc.

waruqi commented 1 month ago

那这种目前解析不了,先得确认库和头文件路径在哪。啥也没有 就没办法了。。

所以建议用 xmake-repo 的 opencv 包

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


This kind of problem cannot be parsed at present. You must first confirm where the library and header file paths are. If there is nothing, there is nothing we can do. .

Therefore, it is recommended to use the opencv package of xmake-repo

KkemChen commented 1 month ago

嗯,我改成 add_requires("vcpkg::opencv4[contrib,freetype]", {alias = "opencv"}),动态库倒是可以用,静态库好像是没有级联依赖 导致报一堆像libpng之类的其他依赖库未定义的错误

star-hengxing commented 1 month ago

嗯,我改成 add_requires("vcpkg::opencv4[contrib,freetype]", {alias = "opencv"}),动态库倒是可以用,静态库好像是没有级联依赖 导致报一堆像libpng之类的其他依赖库未定义的错误

目前 vcpkg/conan 的级联依赖需要一个个声明,动态库自然都包含进去,而静态库需要手动链接

waruqi commented 1 month ago

只有 xmake-repo 仓库的包才支持级联依赖。。三方包不支持

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


Only packages in the xmake-repo warehouse support cascading dependencies. . Third-party packages are not supported