【问题标题】:How do I build sdl2 with meson?如何用介子构建 sdl2?
【发布时间】:2021-10-31 01:21:52
【问题描述】:

使用这个介子文件,

project('mytest', 'c')
cc = meson.get_compiler('c')

deps = []
deps += dependency('sdl2',
  required: true,
  static: true,
  method: 'pkg-config')


executable('demo', 
           'src/main.c', 
           dependencies : deps,
           gui_app: true)

我收到以下错误

 error LNK2019: unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

这似乎与SDLmain.lib有关(我确定它存在)。
你会如何强制链接器链接到这个库?

我在 Windows 10 上,使用 MSVC 编译器。

【问题讨论】:

  • 你链接到SDLmain.lib了吗?
  • 不!你是怎么做到的? dependency 似乎不起作用。

标签: c sdl sdl-2 meson-build


【解决方案1】:

您正在构建一个 gui 应用程序,而不是一个终端应用程序。使用 MSVC,当您设置 gui_app : true(或在介子的更新版本中 win_subsystem : 'windows')时,您不提供 main 函数,而是提供 WinMain 函数。

See the MSDN documentation

在后台,此选项将/SUBSYSTEM:WINDOWS 传递给编译器

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-12
    • 2022-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多