Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

error: no member named 'stdio' in 'union SDL_RWops:: while building #5

Open
derrandz opened this issue Apr 5, 2016 · 16 comments
Open

Comments

@derrandz
Copy link

derrandz commented Apr 5, 2016

Hello,

so I followed the specified steps to build SDL2_image, I did as README-emscripten.txt specified.
the command:

$: emconfigure ./configure --disable-sdltest --with-sdl-prefix=/mycustompath --prefix=/mycustompath

has succeeded, however when I run

$: emmake make

the following error promps out:

$: emmake make
/bin/sh ./libtool  --tag=CC   --mode=compile emcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE=\"SDL2_image\" -DVERSION=\"2.0.0\" -DLOAD_BMP=1 -DLOAD_GIF=1 -DLOAD_LBM=1 -DLOAD_PCX=1 -DLOAD_PNM=1 -DLOAD_TGA=1 -DLOAD_XCF=1 -DLOAD_XPM=1 -DLOAD_XV=1 -I.      -MT IMG.lo -MD -MP -MF .deps/IMG.Tpo -c -o IMG.lo IMG.c
libtool: compile:  emcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE=\"SDL2_image\" -DVERSION=\"2.0.0\" -DLOAD_BMP=1 -DLOAD_GIF=1 -DLOAD_LBM=1 -DLOAD_PCX=1 -DLOAD_PNM=1 -DLOAD_TGA=1 -DLOAD_XCF=1 -DLOAD_XPM=1 -DLOAD_XV=1 -I. -MT IMG.lo -MD -MP -MF .deps/IMG.Tpo -c IMG.c  -fPIC -DPIC -o .libs/IMG.o
IMG.c:184:23: error: use of undeclared identifier 'SDL_RWOPS_STDFILE'
    if ( src->type == SDL_RWOPS_STDFILE ) {
                      ^
IMG.c:189:74: error: no member named 'stdio' in 'union SDL_RWops::(anonymous at
      /home/hrt/Schoolspace/Capstone/Libraries/emsdk_portable/emscripten/master/system/include/SDL/SDL_rwops.h:83:5)'
        data = emscripten_get_preloaded_image_data_from_FILE(src->hidden.stdio.fp, &w, &h);
                                                             ~~~~~~~~~~~ ^
2 errors generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
make: *** [IMG.lo] Error 1

I appreciate the help.

@gsathya
Copy link
Contributor

gsathya commented Apr 5, 2016

cc @Daft-Freak @juj

@Daft-Freak
Copy link
Member

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...

@derrandz
Copy link
Author

derrandz commented Apr 5, 2016

How do I specify the version of SDL for the build?

@gsathya
Copy link
Contributor

gsathya commented Apr 5, 2016

IIRC "-s USE_SDL=2"

@derrandz
Copy link
Author

derrandz commented Apr 5, 2016

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?

@Daft-Freak
Copy link
Member

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.

@derrandz
Copy link
Author

derrandz commented Apr 5, 2016

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.

@Daft-Freak
Copy link
Member

Did you emmake make install SDL2?

@derrandz
Copy link
Author

derrandz commented Apr 5, 2016

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.

@Daft-Freak
Copy link
Member

Make sure --with-sdl-prefix points to the prefix SDL was installed to not the source dir, the bin folder only exists after install.

@derrandz
Copy link
Author

derrandz commented Apr 5, 2016

And where is that?

@Daft-Freak
Copy link
Member

The path passed as --prefix to SDL2 configure.

@derrandz
Copy link
Author

derrandz commented Apr 5, 2016

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.

@Daft-Freak
Copy link
Member

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.

@qufighter
Copy link

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:

  • when using -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.
  • when using -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:
emscripten-core/emsdk@9538381

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!

@Daft-Freak
Copy link
Member

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants