2

I'm trying to make a windowed application with SDL in windows, using ninja to build. When I try to build, I get the error:

lld-link: error: subsystem must be defined

It seems I need to set the /SUBSYSTEM:WINDOWS linker flag for it to work. How can I set that in CMake?

I tried using the WIN32 flag mentioned in add_executable, but the clang command doesn't change when I try to build again, and the error still happens.

I looked at this question too, even though it seems to refer to a different issue, but it didn't help. I also tried the other answer in this question, adding

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")

but it just throws no such file or directory: '/SUBSYSTEM:WINDOWS'.

devil0150
  • 1,350
  • 3
  • 13
  • 36

1 Answers1

2

You can try to use

target_link_options(your_target_name PRIVATE "/SUBSYSTEM:WINDOWS")

See cmake documentation: https://cmake.org/cmake/help/git-stage/command/target_link_options.html

vre
  • 6,041
  • 1
  • 25
  • 39
user2807083
  • 2,962
  • 4
  • 29
  • 37