Replies: 5 comments 32 replies
-
[Chinese translation on original question]
|
Beta Was this translation helpful? Give feedback.
-
既然你的依赖链是这个,那么你 hashlink/xmake.lua 里面,就没必要写全所有,只需要
这不是坑,是你用的不对,不管怎样,始终只需要一个 add_requires("openal-soft 1.23.1")
add_requires("openal-soft.libsndio", {system = false, override = true})
add_requires("openal-soft.libsndio.alsa-lib", {system = false, override = true})
target("hashlink")
add_packages("openal-soft")
要从根路径开始,也就是 如果还是没生效。你也可以递归匹配,改写所有。。 add_requires("openal-soft.**", {system = false, override = true}) 另外,你改
如果你非要用 libsdnio 静态库,只有提 pr 到 xmake-repo ,将 libsndio 支持静态库,去掉 readonly shared 的配置,当然前提是 所有 ci 都得通过,并且解决掉之前遇到的所有静态库编译失败问题或者其他问题。 只要这个包支持了静态库,你用户端,add_requires 啥也不用改,默认用的就是静态库了 |
Beta Was this translation helpful? Give feedback.
-
理论上 xmake install 会 install 所有依赖的 so ,如果没有,应该是 bug ,你应该提 issues 等待修复
如果 openal-soft 真的依赖了 libasound.so 和 libatopology.so,那么这个 link 还是要加的,即使你上层代码没直接调用这两个库接口,但是你调用了 openal-soft 的接口,而它的接口内部实现 可能需要加载使用这两个 so 的部分接口,你不安装它们,一样运行不起来,或者运行到一半出错。。 除非是,你调用的 openal-soft 的那部分接口内部,也完全没有用到 libasound.so 和 libatopology.so , 这种情况下,应该是 改 openal-soft ,加配置禁用 alsa-lib 依赖。。比如 add_configs("no-alsa-lib") 等待,编译出一个完全不依赖 alsa-lib 的 openal-soft 去使用 还有一种情况就是 openal-soft 你用了 so ,而 alsa-lib 用了 static ,那么最终只需要到 openal-soft.so 那一层。 |
Beta Was this translation helpful? Give feedback.
-
另外, 如果你只想一刀切,全部包都完全不走系统查找。那么你可以全局配置 set_policy("package.install_only", true) 记住是全局域配置,不要放到 target 域下面,它会禁用所有包和依赖包的系统库优先使用策略,总是从 xmake-repo 仓库下载安装。 如果这两种都没生效,你应该提 issues 报障,并提供可复现例子。 |
Beta Was this translation helpful? Give feedback.
-
如果上游不积极处理的情况下,一种方案是 自己通过 add_patches 强行让这个包支持静态库。。 但如果这个工作量大,可以换另外一种方案,那就是 port 到 xmake.lua 去编译 libsnd 。。我看这个包的源码接口就那么几个 .c 文件。。即使 不走 autoconf ,port 到 xmake.lua 编译,预计工作量也就一两个小时的时间。反而更省事 可以参考其他一些 port 到 xmake.lua 的包 简单的直接写 on_install 里: https://github.com/xmake-io/xmake-repo/blob/dev/packages/l/libspng/xmake.lua 稍微复杂点的,单独 xmake.lua 文件:https://github.com/xmake-io/xmake-repo/pull/2899/files |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Operating System and Tool info
Manjaro Linux Unstable branch
Xmake:v2.8.5+master.f205de61c (Build by myself)
Scenario
My project tries to build a game VM against static libraries, with a purpose to make build binary useable on any Linux distro. The audio part has a dependency chain like below:
I know libsndio has no static library support yet (see their issue). However, I'm thinking whether it's possible I still set OpenAL and alsa-lib as static. So I set dependencies below: (Full version):
The problem
When building my project, I noticed xmake always ignore xmake::alsa-lib but uses OS provided alsa-lib,
pacman::alsa-lib
. Meanwhile the final link command line still link to-lasound
and-latopology
. So the built binary depends on OS-provided libasound.so and libatopology.so. This is not what I want.I tried to specifically add_packages("xmake::alsa-lib") or run "xrepo install alsa-lib", the behavior does not change.
Besides, no matter I use
add_packages("openal", "libsndio", "alsa-lib")
oradd_packages("openal")
, the final link command always has alsa-lib linking:-lasound -l atopology
. This is the direct cause that my built binary link to system providedpacman::alsa-lib
. Seems no way to disable.Questions to clarify:
-lasound -latopology
in final link command?Btw, the current settings in my project compile all three libraries in shared libraries. Then the behavior is correct.
Beta Was this translation helpful? Give feedback.
All reactions