Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vcpkg packages to include EmscriptenApplication on Emscripten #607

Open
kokulshan opened this issue Nov 19, 2022 · 2 comments
Open
Milestone

Comments

@kokulshan
Copy link

kokulshan commented Nov 19, 2022

Hi!

I am trying to build magnum for Emscripten via vcpkg via: vcpkg install --head corrade magnum[debugtools,gl,primitives,scenegraph,shaders,shaderconverter,shadertools]

It seems for Emscripten, Magnum uses a separate path that uses SDL_SetVideo, but Vcpkg resolves to SDL2 which means SDL_SetVideo is unavailable. I see in the non Emscripten path, SDL_CreateWindow is used instead which looks like the correct API for SDL2.

In the portfile for magnum, it seems like vcpkg actually applies a bunch of patches to make SDL match SDL2?
See https://github.com/microsoft/vcpkg/blob/master/ports/magnum/002-sdl-includes.patch
See https://github.com/microsoft/vcpkg/blob/master/ports/magnum/005-fix-find-sdl2.patch

The logs are:

FAILED: src/Magnum/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o 
C:\Source\vcpkg\BuildToolsRepo\__toolPackages\Windows\Cpp\emsdk\upstream\emscripten\em++.bat -DCORRADE_IS_DEBUG_BUILD -IC:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src -IC:/Source/vcpkg/__vcpkg/buildtrees/magnum/wasm32-emscripten-dbg/src -isystem C:/Source/vcpkg/__vcpkg/installed/wasm32-emscripten/include -isystem C:/Source/vcpkg/__vcpkg/installed/wasm32-emscripten/include/SDL2 -g -g -g -std=c++11 -Wall -Wextra -Wold-style-cast -Winit-self -Werror=return-type -Wmissing-declarations -Wpedantic -fvisibility=hidden -fvisibility-inlines-hidden -Wmissing-prototypes -Wno-shorten-64-to-32 -MD -MT src/Magnum/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o -MF src\Magnum\Platform\CMakeFiles\MagnumSdl2Application.dir\Sdl2Application.cpp.o.d -o src/Magnum/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o -c C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:435:20: error: use of undeclared identifier 'SDL_OPENGL'
    Uint32 flags = SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF;
                   ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:435:31: error: use of undeclared identifier 'SDL_HWSURFACE'
    Uint32 flags = SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF;
                              ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:435:45: error: use of undeclared identifier 'SDL_DOUBLEBUF'
    Uint32 flags = SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF;
                                            ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:440:18: error: use of undeclared identifier 'SDL_RESIZABLE'
        flags |= SDL_RESIZABLE;
                 ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:443:21: error: use of undeclared identifier 'SDL_SetVideoMode'
    if(!(_surface = SDL_SetVideoMode(scaledWindowSize.x(), scaledWindowSize.y(), 24, flags))) {
                    ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:671:20: error: use of undeclared identifier 'SDL_OPENGL'
    Uint32 flags = SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF;
                   ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:671:31: error: use of undeclared identifier 'SDL_HWSURFACE'
    Uint32 flags = SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF;
                              ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:671:45: error: use of undeclared identifier 'SDL_DOUBLEBUF'
    Uint32 flags = SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF;
                                            ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:676:18: error: use of undeclared identifier 'SDL_RESIZABLE'
        flags |= SDL_RESIZABLE;
                 ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:679:21: error: use of undeclared identifier 'SDL_SetVideoMode'
    if(!(_surface = SDL_SetVideoMode(scaledWindowSize.x(), scaledWindowSize.y(), 24, flags))) {
                    ^
C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp:780:5: error: use of undeclared identifier 'SDL_Flip'; did you mean 'SDL_blit'?
    SDL_Flip(_surface);
    ^
C:/Source/vcpkg/__vcpkg/installed/wasm32-emscripten/include/SDL2/SDL_surface.h:102:23: note: 'SDL_blit' declared here
typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
                      ^
11 errors generated.
em++: error: 'C:/Source/vcpkg/BuildToolsRepo/__toolPackages/Windows/Cpp/emsdk/upstream/bin\clang++.exe -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -D__EMSCRIPTEN_major__=3 -D__EMSCRIPTEN_minor__=1 -D__EMSCRIPTEN_tiny__=22 -IC:\Source\vcpkg\BuildToolsRepo\__toolPackages\Windows\Cpp\emsdk\upstream\emscripten\cache\sysroot\include\SDL --sysroot=C:\Source\vcpkg\BuildToolsRepo\__toolPackages\Windows\Cpp\emsdk\upstream\emscripten\cache\sysroot -Xclang -iwithsysroot/include\compat -DCORRADE_IS_DEBUG_BUILD -IC:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src -IC:/Source/vcpkg/__vcpkg/buildtrees/magnum/wasm32-emscripten-dbg/src -isystem C:/Source/vcpkg/__vcpkg/installed/wasm32-emscripten/include -isystem C:/Source/vcpkg/__vcpkg/installed/wasm32-emscripten/include/SDL2 -g3 -g3 -g3 -std=c++11 -Wall -Wextra -Wold-style-cast -Winit-self -Werror=return-type -Wmissing-declarations -Wpedantic -fvisibility=hidden -fvisibility-inlines-hidden -Wmissing-prototypes -Wno-shorten-64-to-32 -MD -MT src/Magnum/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o -MF src\Magnum\Platform\CMakeFiles\MagnumSdl2Application.dir\Sdl2Application.cpp.o.d -c C:/Source/vcpkg/__vcpkg/buildtrees/magnum/src/1e116134c5-105b238d76.clean/src/Magnum/Platform/Sdl2Application.cpp -o src/Magnum/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o' failed (returned 1)

@mosra
Copy link
Owner

mosra commented Nov 19, 2022

I'm intentionally not using the full SDL2 port in Emscripten, because it's significantly larger and none of those extra features are used. Which means, if Vcpkg enables the full SDL2 on Emscripten, Sdl2Application will fail to compile.

Currently I have no plans to support the full SDL2 on Emscripten due to the useless extra baggage that it drags in. The go-to application to use there is EmscriptenApplication instead, unfortunately it doesn't seem to be included in the feature list yet. You could try to add the following youself to "features" in vcpkg.json to enable it, together with changing the "default-features" to not include sdl2application anymore (and ideally include emscriptenapplication on Emscripten instead, but I have no idea if it's possible to express such condition there).

    "emscriptenapplication": {
      "description": "EmscriptenApplication library"
    },

The Vcpkg package is maintained by the community, not by me personally, and the Emscripten support is rather fresh IIRC so a lot of things may be broken there. So this is unfortunately all I can offer right now. Hope it helps at least a bit :)

@kokulshan
Copy link
Author

I had to patch the port to remove the sdl2application from default features and then add emscriptenapplication. It doesnt look like vcpkg has support for platform specific so I just updated a build script on my end to only include emscriptenapplication when I am building emscripten. It builds so far. Thanks!

@mosra mosra changed the title Cannot compile magnum for Emscripten via vcpkg head due to SDL2 issues Update vcpkg packages to include EmscriptenApplication on Emscripten Mar 4, 2023
@mosra mosra added this to the 2023.0a milestone Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants