简体   繁体   English

如何使用介子构建 sdl2?

[英]How do I build sdl2 with meson?

Using this meson file,使用这个介子文件,

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)

I get the following error我收到以下错误

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

This seems to be related to the SDLmain.lib (I'm sure it exist).这似乎与SDLmain.lib (我确定它存在)。
How would you force the linker to link to this library?你会如何强制链接器链接到这个库?

I'm on windows 10, using the MSVC compiler.我在 Windows 10 上,使用 MSVC 编译器。

You're building a gui app, not a terminal app.您正在构建一个 gui 应用程序,而不是一个终端应用程序。 With MSVC, when you set gui_app : true (or in more recent versions of meson win_subsystem : 'windows' ) you don't provide a main function, you provide WinMain function instead.使用 MSVC,当您设置gui_app : true (或在介子win_subsystem : 'windows'更新版本中)时,您不提供main函数,而是提供WinMain函数。

See the MSDN documentation 请参阅 MSDN 文档

Under the hood this option is passing /SUBSYSTEM:WINDOWS to the compiler在幕后,此选项将/SUBSYSTEM:WINDOWS传递给编译器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM