-
Notifications
You must be signed in to change notification settings - Fork 74
Building the Emscripten port
Mátyás Mustoha edited this page Mar 19, 2016
·
11 revisions
I'll download it to dependencies/SDL2_mixer
, build in dependencies/SDL2_mixer/build
, and make install
to dependencies/SDL2_mixer/installdir
. You can use different locations, just don't forget to change the paths in the following steps.
cd dependencies
hg clone https://hg.libsdl.org/SDL_mixer SDL2_mixer
cd SDL2_mixer
mkdir build && cd build
emconfigure ../configure \
CFLAGS="-O3 -s USE_OGG=1 -s USE_VORBIS=1" \
--prefix=`pwd`/../installdir \
--disable-sdltest --enable-shared \
--enable-music-ogg --disable-music-mp3 \
--disable-music-flac --disable-music-midi --disable-music-mod
emmake make install
The SDL2_mixer lib should be now in installdir/lib/
.
You have to tell where SDL_mixer.h
is:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fb20bb5..cddfdcf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -133,6 +133,10 @@ if (BUILD_STATIC_LIBS)
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "YAML: Build testing and parse tools" FORCE)
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "YAML: Build contrib stuff in library" FORCE)
add_subdirectory(dependencies/yaml-cpp-noboost)
+
+ # SDL2_mixer
+ include_directories(dependencies/SDL2_mixer/installdir/include/SDL2)
else()
find_package(ENet REQUIRED)
find_package(yaml-cpp REQUIRED)
unzip data.zip
mkdir build_js && cd build_js
emconfigure cmake .. -DNO_NETWORK=1 -DDISABLE_SYSLIB_CHECKS=1 -DUSE_SDL2_LIBS=1
emmake make smw
This will create smw.bc
.
You have to use all the same C/C++ build flags for linking too:
emcc -o smw.html \
./Binaries/Release/smw.bc \
../dependencies/SDL2_mixer/installdir/lib/libSDL2_mixer.so \
-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png","bmp"]' \
-s USE_ZLIB=1 -s USE_OGG=1 -s USE_VORBIS=1 \
-s ALLOW_MEMORY_GROWTH=1 -s DISABLE_EXCEPTION_CATCHING=0 -s EXCEPTION_DEBUG=1 \
-O3 --preload-file ../data@data
(Don't worry about the unresolved symbol: _Exit
warning)
You should now have smw.html
, ready to play!