Skip to content
New issue

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

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

Already on GitHub? # to your account

utils.symbols.export_all/list 能不能导出C++符号? #6201

Closed
RPG3D opened this issue Mar 9, 2025 · 5 comments
Closed

utils.symbols.export_all/list 能不能导出C++符号? #6201

RPG3D opened this issue Mar 9, 2025 · 5 comments
Labels

Comments

@RPG3D
Copy link

RPG3D commented Mar 9, 2025

Xmake 版本

2.9.8

操作系统版本和架构

windows 11 x64, msvc 14.43

描述问题

#2121
https://github.com/xmake-io/xmake/tree/dev/tests/projects/c/shared_library_export_list
上述示例中,无论是link foo还是foo2都无法link add sub函数
是不是Windows必须dllexport才行

期待的结果

添加utils.symbols.export_all后没有标记dllexport的c++符号可以被其他模块link

工程配置


#pragma once

#ifdef __cplusplus
//extern "C" {
#endif

int add(int a, int b);

#ifdef __cplusplus
//}
#endif

add_rules("mode.release", "mode.debug")

target("foo")
    set_kind("shared")
    add_files("src/foo.c")
    add_rules("utils.symbols.export_list", {symbols = {
        "add",
        "sub"}})

target("foo2")
    set_kind("shared")
    add_files("src/foo.c")
    add_files("src/foo.export.txt")
    add_rules("utils.symbols.export_list")

target("test")
    set_kind("binary")
    add_deps("foo")
    add_files("src/main.c")


附加信息和错误日志

LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup
foo2.exp : error LNK2001: unresolved external symbol add
foo2.exp : error LNK2001: unresolved external symbol sub
build\windows\x64\release\foo2.dll : fatal error LNK1120: 3 unresolved externals
@RPG3D RPG3D added the bug label Mar 9, 2025
@Issues-translate-bot
Copy link

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


Title: utils.symbols.export_all/list Can C++ symbols be exported?

@star-hengxing
Copy link
Contributor

@waruqi
Copy link
Member

waruqi commented Mar 9, 2025

看上面的文档,都有详细说明,支持 c++

@waruqi waruqi closed this as completed Mar 9, 2025
@Issues-translate-bot
Copy link

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


Look at the above documentation, there are detailed instructions, support C++

@RPG3D
Copy link
Author

RPG3D commented Mar 9, 2025

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

No branches or pull requests

4 participants