Open derrandz opened 8 years ago
cc @daft-freak @juj
It looks like the build is finding the SDL 1.3 headers (SDL_RWOPS_STDFILE
is defined in the SDL2 version of SDL_rwops.h
but not the SDL1.3 version).
Also, looks that README file needs some updating...
How do I specify the version of SDL for the build?
IIRC "-s USE_SDL=2"
How do I use -s USE_SDL=2
when the project is built by make..
I mean, in the docs, the use of such option is supplied to the compiler call emcc
..
Do I have to manually modify the Makefile?
If there's an installed SDL2 build at --with-sdl-prefix
it should just work. The recommended way of using SDL2 is to use Emscripten ports (-s USE_SDL=2
and -s USE_SDL_IMAGE=2
). Building it yourself should still work though.
The building of SDL2 went like charm actually, I am struggling to get SDL2_Image to build..
I do supply the built version of SDL2 to the emconfigure
of SDL_image2, yet that problem occurs.
Did you emmake make install
SDL2?
Yes, I did.
However, one thing I noticed when I was ran emconfigure
for SDL2_image
-config: No such file or directory
./configure: line 12524: /.../Libraries/SDL-emscripten/bin/sdl2-config: No such file or directory
./configure: line 12527: /.../Libraries/SDL-emscripten/bin/sdl2-config: No such file or directory
./configure: line 12529: /.../Libraries/SDL-emscripten/bin/sdl2-config: No such file or directory
./configure: line 12531: /.../Libraries/SDL-emscripten/bin/sdl2-config: No such file or directory
And I noticed that there is no bin directory in SDL-emscripten.
Make sure --with-sdl-prefix
points to the prefix SDL was installed to not the source dir, the bin folder only exists after install.
And where is that?
The path passed as --prefix
to SDL2 configure.
Since it was not specified in README-emscripten.txt
, I haven't specified it explicitly and I think it was put in /usr/local
To avoid ambiguity I have re-ran emconfigure
with a --prefix
and supplied it to SDL2_image configure, now everything works.
I apologize for the inconvenience, thank you.
Ah, didn't notice that the SDL2 docs don't mention specifying a prefix. I don't think the instructions for building SDL2_image have been updated since the initial port. I'll go and update that now.
I definitely had some trouble getting this working on my system, which happens to be OSX... I didn't install any libs though (and don't plan to since where would they go anyway?). In any case here is what worked for me. There is some more scripting before this to copy all needed files into /.fs
emcc ../*.cpp ../Platform/Emscripten/*.cpp -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s STB_IMAGE=1 -s TOTAL_MEMORY=1073741824 -s "BINARYEN_TRAP_MODE='clamp'" -s ERROR_ON_UNDEFINED_SYMBOLS=0 -I/full/path/to/locally/cloned/emscripten-ports/SDL2/include -I/full/path/to/locally/cloned/emscripten-ports/SDL2_image/ -o hello.html --preload-file ./fs@/ --exclude-file *.DS_Store --use-preload-plugins -s ALLOW_MEMORY_GROWTH=1
It takes a few tries... since it doesn't have the auto cloned ports until the first run, so after the first failure I apply the hacks below. I can't quite understand why when I've specified /full/path/to/locally/cloned/emscripten-ports/SDL2/include
when it tries to build SDL Image it can't find or ignores those headers I've specified... so I instead manually copied the SDL headers into the SDL image folder... nasty but it worked... and had to make some small changes... (seriously this was a last resort, I tried nearly everything else I could think of even modifying some of the python, but this actually worked for me).
# hacks documented (note the versions you get may vary)
$ cd ~/.emscripten_ports/sdl2_image/SDL2_image-version_4
$ cp ../../sdl2/SDL2-version_17/include/* .
# next we hack two files of SDL2_image-version_4....
# IMG.c
# + #include <stdlib.h>
# SDL_rwops.h
# + include <stdio.h>
# + define HAVE_STDIO_H
So the strange things... my project won't build because the header files are not found, so I'm already needing to specify the paths to the necessary header files (which means I already have my own copy of emscripten_ports locally )... but when it tries to find the headers to build SDL_Image the ones I specified are ignored.
I understand that there is probably a way around this using a prefix path and actually installing the headers there. At first I was trying to not use either of the -s USE*
flags and just build it myself from sdl 2.0.9 since the ports looked out of date, but those didn't work (maybe I need a flag to disable SDL version 1 somehow... without forcing the automatic version 2 either?). So in any case this (above) is how I got it working without any install
commands.
I wonder about the possibility of one of these:
-s USE_SDL=2
and -s USE_SDL_IMAGE=2
that my project can find all the SDL headers magically instead of needing to specify full paths.-s USE_SDL_IMAGE=2
in conjunction with -s USE_SDL=2
that SDL image 2 can find the headers for SDL2.I'm using this version of emsdk: https://github.com/emscripten-core/emsdk/commit/9538381d56272818cba77a808ba46fdac6c961c8
I would post a link to my WASM build, but thats not the purpose of this post, just trying to help anyone who is stuck and possibly figure out why I had so much trouble and spend so much time trying to figure this out. Thanks!
The -s USE_*
flags are definitely supposed to set the include path for you (https://github.com/emscripten-core/emscripten/blob/incoming/tools/ports/sdl2.py#L68). If it isn't you might want to create an issue in emscripten.
Hello,
so I followed the specified steps to build SDL2_image, I did as
README-emscripten.txt
specified. the command:has succeeded, however when I run
the following error promps out:
I appreciate the help.