Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmake l find_packages failed after conan install packages #1489

Closed
meet-ai opened this issue Jul 4, 2021 · 8 comments
Closed

xmake l find_packages failed after conan install packages #1489

meet-ai opened this issue Jul 4, 2021 · 8 comments

Comments

@meet-ai
Copy link

meet-ai commented Jul 4, 2021

Note: If you use the fuzzy expressions such as 'can't use/no effect/problem/error', but don't give any relevant auxiliary information according to the template below, this issue will be not replied.

Describe the bug

xmake l find_packages after conan install failed

root@docker-desktop:/folly# conan search folly
Existing package recipes:

folly/2020.08.10.00

xmake l find_packages conan::folly/2020.08.10.00
{}

Expected behavior

found one.

Error output

root@docker-desktop:/folly# xmake l -v find_packages conan::folly/2020.08.10.00
running builtin module find_packages with args:

  • "conan::folly/2020.08.10.00"
    find package conan folly/2020.08.10.00
    conan get buildinfo /folly/build/.conan/folly/2020.08.10.00/conanbuildinfo.xmake.lua
    checking for conan::folly/2020.08.10.00 ... no
    { }

If it is a xmake related compilation problem, please add the -v -D parameter and give the detailed compilation output information.

Related Environment

Please provide compiling and running environment information:

Additional context

Add any other context about the problem here.

1 为什么会查找项目下面的 build 路径里面找 conan 的 包
2 conan 安装的包, 应该跟 xmake 无交集, 为何查找 conanbuildinfo.xmake.lua , 这个文件应该不会生成吧.

@waruqi
Copy link
Member

waruqi commented Jul 4, 2021

都安装失败了,去 find_packages 当然找不到了,失败了就 -vD 贴下 完整失败信息

$ xmake f -c -vD
Downloading conan_export.tgz completed [0.25k]
Decompressing conan_export.tgz completed [0.00k]
openssl/1.1.1k: Downloaded recipe revision 0
ERROR: Conflict in cmake/3.16.2:
    'cmake/3.16.2' requires 'openssl/1.1.1k' while 'libevent/2.1.12' requires 'openssl/1.1.1i'.
    To fix this conflict you need to override the package 'openssl' in your root package.
error: @programdir/core/sandbox/modules/os.lua:392: execv(/usr/local/bin/conan install . --build=m
issing -s os=Macos -s arch=x86_64 -s build_type=Release) failed(1)
stack traceback:

我这里 mac 上测试,是它内部安装出错了,你这的情况,自己看下错误详情,自己调整下环境,xmake 也仅仅只是调用 conan install ,错误也都是 conan 自身出错。如果解不了,你也应给 conan 那边提 issues

1 为什么会查找项目下面的 build 路径里面找 conan 的 包
2 conan 安装的包, 应该跟 xmake 无交集, 为何查找 conanbuildinfo.xmake.lua , 这个文件应该不会生成吧.

conan 装的包,都是根据 sha256 分的目录,你直接是找不到具体哪个的,必须走它的脚本导出一个适配层,获取内部的 linkdirs/includedirs 等信息,都在 conanbuildinfo.xmake.lua 里面,这也是 conan 官方推荐的做法。。build 下并没有 conan 的包,仅仅只是为了接入获取安装后包的详情。。

@meet-ai
Copy link
Author

meet-ai commented Jul 4, 2021

感谢 @waruqi
所以这里查找的目标 package 也必须使用 xmake 调用 conan 安装. 看来我误解了文档里面的话,以为是可以直接使用 conan 安装然后使用 xmake 查找. 这样 xmake 会自动生成 conanbuildinfo.xmake.lua 就说的通了.

并且通过系统和第三方包管理工具进行依赖包的安装,然后与xmake进行集成使用,例如我们查找一个openssl包:
local packages = find_packages("openssl", "zlib")

https://xmake.io/#/zh-cn/package/system_package

$ xrepo install brew::zlib
$ xrepo install vcpkg::zlib
$ xrepo install conan::zlib/1.2.11
https://xrepo.xmake.io/#/zh-cn/getting_started?id=%e5%ae%89%e8%a3%85%e8%b0%83%e8%af%95%e7%89%88%e6%9c%ac%e5%8c%85

@waruqi
Copy link
Member

waruqi commented Jul 4, 2021

尽量走 add_requires/add_packages,如果你自己已经安装了 conan 包,add_requires 并不会重复安装,也是优先使用 你装的包 或者系统库。。你也可以禁用安装,强制只走系统库,add_requires("xx", {system = true}) 等价于 find_packages

走原始 find_packages 仅对 brew /vcpkg 的包有效,但是对于 conan 包比较特殊,直接找是找不到的,只能走 add_requires 来集成,内部也会自动先调用 find_packages 来找。。

@meet-ai meet-ai closed this as completed Jul 4, 2021
@endingly
Copy link

endingly commented Apr 5, 2022

今天刚尝鲜就卡住了,我的配置是下面这样的,系统环境是 windows 11

add_rules("mode.debug","mode.release")
set_languages("c++17")
-- { debug=true }
add_requires("vcpkg::gtest")
add_requires("vcpkg::libhv[ssl]")

target("ctime")
    set_kind("binary")
    add_files("src/*.cpp")
    add_includedirs("include")
    add_packages("vcpkg::gtest","vcpkg::libhv[ssl]")

不知道为什么按照上面这个配置,xmake跑完之后,工程文件中没有办法 #include<gtest/gtest.h> ,大佬知道是为什么吗?还是说是 bug 11 惹的祸?

@waruqi
Copy link
Member

waruqi commented Apr 5, 2022

xmake-repo 仓库有 gtest 和 libhv 干嘛不用,非得用 vcpkg 的

@endingly
Copy link

endingly commented Apr 5, 2022

@waruqi 用了xmake-repo 的 gtest 也还是这样,在 vscode 当中仍然是红色波浪线,重启软件和计算机完全不起作用
image

@waruqi
Copy link
Member

waruqi commented Apr 5, 2022

@waruqi 用了xmake-repo 的 gtest 也还是这样,在 vscode 当中仍然是红色波浪线,重启软件和计算机完全不起作用 image

那是 intellegense 的问题,自己配置 vscode ,跟 xmake 没啥关系,编译能过,就是正常

@waruqi
Copy link
Member

waruqi commented Apr 6, 2022

跟 这个 issues 无关的问题,单独开 issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants