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

Emscripten build issues and build instructions #777

Closed
rendaw opened this issue Nov 20, 2018 · 4 comments
Closed

Emscripten build issues and build instructions #777

rendaw opened this issue Nov 20, 2018 · 4 comments
Assignees

Comments

@rendaw
Copy link

rendaw commented Nov 20, 2018

First of all, AFAICT from git history the project switched from a handmade Makefile to CMake recently and it looks like the build instructions on the wiki are out of date.

I'm trying to build the WASM version, I use these commands:

emcmake cmake . && emmake make

but linking tic80.js fails with:

[ 85%] Linking CXX executable bin/tic80.js
/usr/bin/cmake -E cmake_link_script CMakeFiles/tic80.dir/link.txt --verbose=1
/usr/lib/emscripten/em++     @CMakeFiles/tic80.dir/objects1.rsp  -o bin/tic80.js @CMakeFiles/tic80.dir/linklibs.rsp
warning: unexpected number of arguments 1 in call to 'getClipboardEvent', should be 0
error: undefined symbol: SDL_BuildAudioCVT
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
error: undefined symbol: SDL_CloseAudioDevice
error: undefined symbol: SDL_ConvertAudio
error: undefined symbol: SDL_CreateSystemCursor
error: undefined symbol: SDL_CreateWindow
error: undefined symbol: SDL_GL_CreateContext
error: undefined symbol: SDL_GL_GetDrawableSize
error: undefined symbol: SDL_GetClipboardText
error: undefined symbol: SDL_GetColorKey
error: undefined symbol: SDL_GetPerformanceCounter
error: undefined symbol: SDL_GetPerformanceFrequency
error: undefined symbol: SDL_GetWindowFromID
error: undefined symbol: SDL_GetWindowID
error: undefined symbol: SDL_HasClipboardText
error: undefined symbol: SDL_JoystickGetAttached
error: undefined symbol: SDL_OpenAudioDevice
error: undefined symbol: SDL_PauseAudioDevice
error: undefined symbol: SDL_QueueAudio
error: undefined symbol: SDL_SetClipboardText
error: undefined symbol: SDL_SetCursor
error: undefined symbol: SDL_SetHint
error: undefined symbol: SDL_SetWindowIcon
error: undefined symbol: SDL_SetWindowSize
error: undefined symbol: SDL_ShowSimpleMessageBox
error: undefined symbol: SDL_memcpy
error: undefined symbol: glColor4f
error: undefined symbol: glColor4ub
error: undefined symbol: glEnd
error: undefined symbol: glGetTexImage
error: undefined symbol: glGetTexLevelParameteriv
error: undefined symbol: glLoadMatrixf
error: undefined symbol: glTexCoord2f
error: undefined symbol: glVertex3f
error: undefined symbol: glXGetClientString
error: undefined symbol: glXGetProcAddressARB
error: undefined symbol: glXQueryVersion
Error: Aborting compilation due to previous errors
ERROR:root:'/usr/bin/node /usr/lib/emscripten/src/compiler.js /tmp/tmpr74l339j.txt /usr/lib/emscripten/src/library_pthread_stub.js' failed (1)
$ cat CMakeFiles/tic80.dir/objects1.rsp 
CMakeFiles/tic80.dir/src/net.c.o CMakeFiles/tic80.dir/src/system.c.o CMakeFiles/tic80.dir/src/ext/file_dialog.c.o
$ cat CMakeFiles/tic80.dir/linklibs.rsp 
lib/libtic80lib.a lib/libsdlnet.a lib/libsdlgpu.a lib/libtic80core.a lib/liblua.a lib/liblpeg.a lib/libwren.a lib/libsquirrel.a lib/libgiflib.a lib/libzlib.a

I can't say I'm familiar with emscripten and I've made about a million mistakes getting this far so it's possible I missed something. I thought the SDL_ ones at least would have been built by 3rd-party/sdl-gpu... I see that compiled into a .a file earlier in the log.

Glad to update the wiki if someone can help me get this working.

Linux
cmake 3.12.4
emcc 1.38.15

@rendaw
Copy link
Author

rendaw commented Nov 21, 2018

AFAICT the gl symbol errors are due to https://github.com/nesbox/TIC-80/blob/master/CMakeLists.txt#L289
DSDL_GPU_DISABLE_OPENGL should be SDL_GPU_DISABLE_OPENGL. Can anyone confirm?

Still stuck with the SDL_ symbol errors though.

@rendaw
Copy link
Author

rendaw commented Nov 21, 2018

Ah, it looks like -s USE_SDL=2 needs to be in the linking as well:

-       if(NOT EMSCRIPTEN)
+       if(EMSCRIPTEN)
+               target_link_libraries(${TIC80_OUTPUT} "-s USE_SDL=2")
+       else()
                add_dependencies(${TIC80_OUTPUT} SDL2main SDL2-static)
                target_link_libraries(${TIC80_OUTPUT} SDL2-static SDL2main)
        endif()

https://github.com/nesbox/TIC-80/blob/master/CMakeLists.txt#L482

Is my system nonstandard in this regard? Anyway, leaving the information here in case someone else has the issue. I'll close this in a few days if there's no interest.

@rendaw
Copy link
Author

rendaw commented Nov 21, 2018

It looks like -s TOTAL_MEMORY also needs to be in the link flags? I'm getting errors about 16mb memory limit without.

@rendaw rendaw changed the title Emscription build issues and build instructions Emscripten build issues and build instructions Nov 25, 2018
@nesbox nesbox added this to the 0.80.0 milestone Jul 14, 2019
@nesbox nesbox self-assigned this Jul 14, 2019
nesbox added a commit that referenced this issue Jul 14, 2019
@nesbox
Copy link
Owner

nesbox commented Jul 14, 2019

Fixed Emscripten build.
Thank you.

@nesbox nesbox closed this as completed Jul 14, 2019
@nesbox nesbox removed this from the 0.80.0 milestone Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants