xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.14k stars 782 forks source link

XMake 在 Windows 系统下 build 会出现 LNK 1104 错误 #5550

Closed AImixAE closed 2 months ago

AImixAE commented 2 months ago

Xmake 版本

v2.9.4+master.21ae0fa44

操作系统版本和架构

Windows 11 23H2 64位

描述问题

我的项目先 构建了一个动态库 ,随后再构建exe程序,但是在链接DLL时就会报错LNK 1104 但是在 Linux 环境下使用xmake b不会出现问题

期待的结果

之后在 Windows 平台下可以顺利的build

工程配置

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

target("libmath.shared")
    set_kind("shared")
    add_files("src/math/*.cpp")

target("main")
    set_kind("binary")
    add_files("src/*.cpp")

    add_deps("libmath.shared")

附加信息和错误日志

xmake f -m debug -v

configure
{
    arch = x64
    plat = windows
    ccache = true
    network = public
    host = windows
    ndk_stdcxx = true
    vs = 2022
    mode = debug
    buildir = build
    theme = default
    proxy_pac = pac.lua
    clean = true
    kind = static
}

xmake b main

[ 37%]: compiling.debug src\math\math.cpp
[ 50%]: compiling.debug src\main.cpp
[ 62%]: linking.debug libmath.shared.dll
[ 87%]: linking.debug main.exe
error: LINK : fatal error LNK1104: 无法打开文件“libmath.shared.lib”
Issues-translate-bot commented 2 months ago

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


Title: XMake will produce LNK 1104 error when building under Windows system

AImixAE commented 2 months ago

我在我的项目里也没有找到任何以.lib为后缀的文件

Issues-translate-bot commented 2 months ago

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


I didn't find any files with the suffix .dll in my project.

star-hengxing commented 2 months ago

https://github.com/xmake-io/xmake/issues/5026

waruqi commented 2 months ago

你的动态库没导出符号,自己参考上面的回复导出下

Issues-translate-bot commented 2 months ago

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


Your dynamic library does not export symbols. Please refer to the reply above to export them yourself.

AImixAE commented 2 months ago

使用__declspec(dllexport)时就好了,谢谢!

Issues-translate-bot commented 2 months ago

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


It's fine when using __declspec(dllexport), thank you!