SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Cannot compile src/audio/SDL_wave.c with /ZW

Open Zopolis4 opened this issue 3 years ago • 6 comments

As per title. I am trying to compile a project of mine that uses SDL as a dependency, but it is unable to compile src/audio/SDL_wave.c with the /ZW option (required for UWP/Windows Runtime builds).

Zopolis4 avatar Jul 19 '22 10:07 Zopolis4

Can you paste the compiler error message into a comment here?

icculus avatar Jul 21 '22 01:07 icculus

cl : Command line error D8048 : cannot compile C file 'SDL_audio.c' with the /ZW option It has since come to my attention that this error is because C files cannot be compiled with the /ZW option, so I'm not really sure how SDL normally produces UWP builds.

Zopolis4 avatar Jul 21 '22 06:07 Zopolis4

Can you please try the patch below? Perhaps overriding the language works. It fails to build for me though due to the sources not being c++ compatible. Perhaps this might be useful? Compiling code in c++ mode exposes issues. Adding -Wc++-compat for gcc/clang adds the same checks.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12d6eced9..0df034326 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2998,6 +2998,8 @@ endif()
 # Ensure that the extra cflags are used at compile time
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${EXTRA_CFLAGS_BUILD}")
 
+set_source_files_properties(${SOURCE_FILES} ${SDLMAIN_SOURCES} PROPERTIES LANGUAGE CXX)
+
 if(NOT WINDOWS_STORE AND NOT SDL2_DISABLE_SDL2MAIN)
   # Build SDLmain
   add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
@@ -3133,6 +3135,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MICRO_VERSION=${SDL_MICRO_VERSIO
 
 if(SDL_TEST)
   file(GLOB TEST_SOURCES ${SDL2_SOURCE_DIR}/src/test/*.c)
+  set_source_files_properties(${TEST_SOURCES} PROPERTIES LANGUAGE CXX)
   add_library(SDL2_test STATIC ${TEST_SOURCES})
   add_dependencies(SDL2_test sdl_headers_copy)
   add_library(SDL2::SDL2test ALIAS SDL2_test)

madebr avatar Jul 21 '22 11:07 madebr

The VisualC-WinRT directory has a .sln file that can build SDL for UWP. I'm not sure we've seriously tried to do it with CMake yet.

(Unless something has recently broken, the VisualC-WinRT project files still work.)

icculus avatar Jul 21 '22 23:07 icculus

I don't think compiling SDL as C++ is the best way to do it, from what I can see of the VisualC-WinRT directory it doesn't do it that way. I can't really use the .sln file because what I'm doing is heavily CMake based, unfortunately.

Zopolis4 avatar Aug 17 '22 23:08 Zopolis4

In https://github.com/libsdl-org/SDL/pull/7633, building tests with UWP is added. Assuming you are building with -DCMAKE_SYSTEM_NAME="WindowsStore", perhaps that will help you?

madebr avatar May 23 '23 22:05 madebr

SDL 2.0 is now in maintenance mode, and all inactive issues are being closed. If this issue is impacting you, please feel free to reopen it with additional information.

slouken avatar Nov 07 '23 15:11 slouken