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

binary target 无法 add_deps 一个 static / shared target #4923

Closed
TOMO-CAT opened this issue Apr 2, 2024 · 6 comments
Closed

binary target 无法 add_deps 一个 static / shared target #4923

TOMO-CAT opened this issue Apr 2, 2024 · 6 comments
Labels

Comments

@TOMO-CAT
Copy link

TOMO-CAT commented Apr 2, 2024

Xmake 版本

xmake v2.8.9+dev.50dbca648

操作系统版本和架构

Linux 720ce3a659a2 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

描述问题

当我基于多个 object target 组成一个 static / shared target:
image
在尝试 add_deps 这个 static / shard target 时会发现不会自动 -lxxxx:
image

手动补上对应的链接参数可以正常编译运行:
image

期待的结果

我猜是因为我这个 static target 只是聚合多个 object targets,没有自己的 cc 文件触发的 bug?希望可以 add_deps 引用 static target。

工程配置

可以复现的最小 demo:

https://github.com/TOMO-CAT/xmake-template/blob/main/missed_static_deps/xmake.lua

附加信息和错误日志

$ xmake --version
xmake v2.8.9+dev.50dbca648, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
                         _
    __  ___ __  __  __ _| | ______
    \ \/ / |  \/  |/ _  | |/ / __ \
     >  <  | \__/ | /_| |   <  ___/
    /_/\_\_|_|  |_|\__ \|_|\_\____|
                         by ruki, xmake.io
    
    👉  Manual: https://xmake.io/#/getting_started
    🙏  Donate: https://xmake.io/#/sponsor
@TOMO-CAT TOMO-CAT added the bug label Apr 2, 2024
@star-hengxing
Copy link
Contributor

给 util 加上 add_rules("c++")。因为该 target 没有 add_files,所以没去应用这个 rule。
我认为这不是 xmake 的 bug,因为 obj 文件也可以来自其他 native 语言,而 target 不应该知道自己会给谁调用

@Issues-translate-bot
Copy link

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


Add add_rules("c++") to util. Because the target does not have add_files, this rule is not applied.
I think this is not a bug of xmake, because the obj file can also come from other native languages, and the target should not know who it will call

@waruqi
Copy link
Member

waruqi commented Apr 2, 2024

嗯,没任何 cpp 文件,是无法自动识别当前 target 是 c++ 项目,也就没法走 c++ 的静态库继承逻辑,只能显式通过 add_rules("c++") 配置下,或者加个空的 cpp 文件

@Issues-translate-bot
Copy link

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


Well, without any cpp file, it is impossible to automatically identify that the current target is a C++ project, so there is no way to use the static library inheritance logic of C++. It can only be configured explicitly through add_rules("c++")

@TOMO-CAT
Copy link
Author

TOMO-CAT commented Apr 3, 2024

嗯,没任何 cpp 文件,是无法自动识别当前 target 是 c++ 项目,也就没法走 c++ 的静态库继承逻辑,只能显式通过 add_rules("c++") 配置下,或者加个空的 cpp 文件

好的,加上后 ok 了。

@TOMO-CAT TOMO-CAT closed this as completed Apr 3, 2024
@Issues-translate-bot
Copy link

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


Well, without any cpp file, it is impossible to automatically recognize that the current target is a C++ project, so there is no way to use the static library inheritance logic of C++. You can only explicitly configure it through add_rules("c++"), or add an empty cpp file

Okay, after adding it it’s ok.

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

No branches or pull requests

4 participants