switchbrew / switch-examples

Switch examples for devkitA64 and libnx.
https://devkitpro.org/viewforum.php?f=42
569 stars 101 forks source link

Sdl2 audio example #53

Closed jonyluke closed 5 years ago

WinterMute commented 5 years ago

SDL2 examples should use sdl2-config. See https://github.com/switchbrew/switch-examples/blob/master/graphics/sdl2/sdl2-simple/Makefile#L55 & https://github.com/switchbrew/switch-examples/blob/master/graphics/sdl2/sdl2-simple/Makefile#L62

Also: I think if we're going to add more sdl2 examples then we should probably move them all to an sdl2 folder rather than sub folders in other categories. Thoughts @fincs & @yellows8 ?

fincs commented 5 years ago

I would be fine either way.

fincs commented 5 years ago

Also another comment: This example should probably use romfs, and a small royalty free mp3 inside romfs; to make it work out of the box.

jonyluke commented 5 years ago

SDL2 examples should use sdl2-config. See https://github.com/switchbrew/switch-examples/blob/master/graphics/sdl2/sdl2-simple/Makefile#L55 & https://github.com/switchbrew/switch-examples/blob/master/graphics/sdl2/sdl2-simple/Makefile#L62

Also: I think if we're going to add more sdl2 examples then we should probably move them all to an sdl2 folder rather than sub folders in other categories. Thoughts @fincs & @yellows8 ?

I've tried that, but compilation fails

yellows8 commented 5 years ago

"compilation fails" What errors?

jonyluke commented 5 years ago

A few lines of make

linking sdl2-audio.elf
c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.3.0/../../../../aarch64-none-elf/bin/ld.exe: main.o: in function `main':
C:/Users/jony8/projects/sdl2-audio/source/main.c:26: undefined reference to `Mix_Init'
c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.3.0/../../../../aarch64-none-elf/bin/ld.exe: C:/Users/jony8/projects/sdl2-audio/source/main.c:30: undefined reference to `Mix_OpenAudio'
c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.3.0/../../../../aarch64-none-elf/bin/ld.exe: C:/Users/jony8/projects/sdl2-audio/source/main.c:33: undefined reference to `Mix_LoadMUS'
c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.3.0/../../../../aarch64-none-elf/bin/ld.exe: C:/Users/jony8/projects/sdl2-audio/source/main.c:49: undefined reference to `Mix_PlayMusic'
c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.3.0/../../../../aarch64-none-elf/bin/ld.exe: C:/Users/jony8/projects/sdl2-audio/source/main.c:56: undefined reference to `Mix_FreeMusic' 
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/libnx/switch_rules:80: /home/jony8/projects/sdl2-audio/sdl2-audio.elf] Error 1
make: *** [Makefile:165: build] Error 2
jonyluke commented 5 years ago

Now it works

jonyluke commented 5 years ago

Added romfs and a sound Sound is from https://freesound.org/people/jens.enk/sounds/434610/