bazel build win32 app

334 views
Skip to first unread message

den....@gmail.com

unread,
Jan 24, 2018, 10:47:56 AM1/24/18
to bazel-discuss
Hi all,

I want to build with bazel simple window application for windows.
But I cannot build it with such main function:

int __stdcall wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)

I get this error - msvcrtd.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ).

I tried to pass /SUBSYSTEM:WINDOWS option to linker with linkopts like this:

cc_binary(
name = "hello-window",
srcs = glob(["*.cpp"]),
copts = ["/D", "_UNICODE", "/D", "UNICODE"],
linkopts = ["/SUBSYSTEM:WINDOWS"],
nocopts = "/J"
)

but I get this error message: "ERROR: D:/projects/bazel/hellowindow/BUILD:5:16: in linkopts attribute of cc_binary rule //:hello-window: could not resolve label '/SUBSYSTEM:WINDOWS' ".

Could someone help me - what am I doing wrong and can I build app with such main function?

Thanks.

Yun Peng

unread,
Jan 24, 2018, 11:15:10 AM1/24/18
to den....@gmail.com, bazel-discuss
Hi,

Bazel doesn't allow flags starting with "/" in linkopts, please try "-SUBSYSTEM:WINDOWS"

Good luck,
Yun

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/5d2eb2f1-3b6a-42f6-84ae-76593fa447b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

den....@gmail.com

unread,
Jan 24, 2018, 2:02:02 PM1/24/18
to bazel-discuss
среда, 24 января 2018 г., 19:15:10 UTC+3 пользователь Yun Peng написал:
Hi Yun,

It works!
Thanks you so much for your help!

--
Best Regards,
Denis

Yun Peng

unread,
Jan 24, 2018, 2:13:16 PM1/24/18
to den....@gmail.com, bazel-discuss
Glad to hear that!

Reply all
Reply to author
Forward
0 new messages