Open AlectronikForge opened 2 years ago
Unfortunately, I have zero experience with Swift on Windows/WSL. However, this project (as-is) requires the SDL2 libraries, and specifically on macOS, expects them to be installed using Homebrew.
You could try installing Homebrew under WSL, then use brew
to install SDL2 libraries. If you're able to get that far, try running sdl2-config
to see the location of where the libs are on the WSL system.
That's as much help as I can offer. Good luck.
I'm trying to do the same thing. I'm getting one step beyond you @AlectronikForge -- your error looks like a Package.swift formatting issue from the error name. simplify it until it compiles and add back in as you go
Even still, i'm compiling but getting a linker error when trying to compile the first example in my own project on WSL like this:
error: link command failed with exit code 1 (use -v to see invocation)
/home/arckex/Advent-of-Code-Swift/.build/x86_64-unknown-linux-gnu/debug/SwiftSDL2.build/SDLTexture.swift.o:SDLTexture.swift.o:function $sSo15IMG_LoadTextureys13OpaquePointerVSgAD_SPys4Int8VGSgtFTO: error: undefined reference to 'IMG_LoadTexture'
maybe all related to a similar error i get when trying to make this project itself
/home/arckex/SwiftSDL/Sources/CreateWindowDemo/main.swift:55:20: error: cannot find 'SDL_KeyCode' in scope
switch SDL_KeyCode(UInt32(event.key.keysym.sym)) {
^~~~~~~~~~~
@andymule similarly: are you also able to simplify the CreateWindowDemo
further until it compiles? Eg., comment out input events. You seem pretty close! 🎉
Even with SDL2, there's going to be platform-specific code paths that exist. While I don't doubt SDL2's ability to handle a multitude of different platforms, is there evidence from the WSL/C/SDL2 community that a working baseline exists?
Same linker error when I comment out the input stuff, so it seems like 2 separate but (relatively small!) issues. 1) missing/wrong input header for KeyCode 2) bad link on loadTexture
/home/arckex/SwiftSDL/.build/x86_64-unknown-linux-gnu/debug/SwiftSDL2.build/SDLTexture.swift.o:SDLTexture.swift.o:function $sSo15IMG_LoadTextureys13OpaquePointerVSgAD_SPys4Int8VGSgtFTO: error: undefined reference to 'IMG_LoadTexture'
This demo DOES run for me (opens a window!), but the library seems much less featured https://github.com/ctreffs/SwiftSDL2
Same linker error when I comment out the input stuff, so it seems like 2 separate but (relatively small!) issues. 1) missing/wrong input header for KeyCode 2) bad link on loadTexture
/home/arckex/SwiftSDL/.build/x86_64-unknown-linux-gnu/debug/SwiftSDL2.build/SDLTexture.swift.o:SDLTexture.swift.o:function $sSo15IMG_LoadTextureys13OpaquePointerVSgAD_SPys4Int8VGSgtFTO: error: undefined reference to 'IMG_LoadTexture'
This demo DOES run for me (opens a window!), but the library seems much less featured https://github.com/ctreffs/SwiftSDL2
sdl_image
is a separate library. Be sure you've installed it and it's being linked (much like you did for sdl
itself).
for the linking, it's a capitalization error w.r.t. pkg-config (at least on Linux)
here's the fix (just capitalizing the pkgConfig name from sdl to SDL)
.systemLibrary( name: "CSDL2_Image", pkgConfig: "SDL2_image"
, providers: [
.brew(["sdl2_image"]),
.apt(["libsdl2-image-dev"]) ]
),
.systemLibrary( name: "CSDL2_Mixer", pkgConfig: "SDL2_mixer"
, providers: [
.brew(["sdl2_mixer"]),
.apt(["libsdl2-mixer-dev"]) ]
),
.systemLibrary( name: "CSDL2_TTF", pkgConfig: "SDL2_ttf"
, providers: [
.brew(["sdl2_ttf"]),
.apt(["libsdl2-ttf-dev"]) ]
),
I'll see if i can figure out input stuff tomorrow. Thanks!
Any update @andymule?
I didn't dig all the way into it. I found another SDL lib that had working keyboard input, so it's probably not TOO much work to figure out the difference between them: https://github.com/fireblade-engine/ecs-demo
I ended up using this raylib port instead of both these libs though: https://github.com/STREGAsGate/Raylib
I'm experimenting with Switf and found your project to bring SDL2 to Swift. Unfortunately, it doesn't compile and bails out with the following message:
SwiftSDL git:(master) make swift build -Xlinker -L/opt/homebrew/lib -Xlinker -lsdl2 -Xlinker -lsdl2_image 'swiftsdl': error: invalidManifestFormat("Missing or empty JSON output from manifest compilation for swiftsdl", diagnost icFile: nil) make: *** [Makefile:7: build] Error 1
Do you have any advice of where to start looking? I'm new to Swift and SDL but not programming in general (mostly C, Ruby etc).