Duke4.net Forums: Build failure due to SDL_USEFOLDER - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Build failure due to SDL_USEFOLDER

User is offline   HiPhish 

#1

Hello everyone,

I'm trying to build eDuke on GNU/Linux and I have a problem: the build fails because of the SDL_USEFOLDER preprocessor symbol.
In file included from source/build/include/mutex.h:10:0,
                 from source/build/include/osd.h:12,
                 from source/build/include/baselayer.h:11,
                 from source/duke3d/src/duke3d.h:28,
                 from source/duke3d/src/sdlmusic.cpp:35:
source/build/include/sdl_inc.h:63:25: fatal error: SDL_mixer.h: No such file or directory
compilation terminated.
Failed building obj/duke3d/sdlmusic.o from source/duke3d/src/sdlmusic.cpp!
make: *** [GNUmakefile:982: obj/duke3d/sdlmusic.o] Error 1


The offender is the file `source/build/include/sdl_inc.h` at line 63 (second-to-laste line in the snippet below):
# if defined SDL_USEFOLDER
#  if SDL_TARGET == 2
#   include <SDL2/SDL_mixer.h>
#  else
#   include <SDL/SDL_mixer.h>
#  endif
# else
#  include "SDL_mixer.h"
# endif


If I remove the surrounding `#if defined ...` everything compiles fine, the compiler looks for the header file in the correct location, the game compiles and everything runs normall. This leads me to believe that somehow the symbol was not defined properly and as a consequence to compiler starts looking for the SDL Mixer header in the same directory as the source code.

On the other hand, on line 15 we have a similar situation:
#if defined SDL_USEFOLDER
# if SDL_TARGET == 2
#  include <SDL2/SDL.h>
#  include <SDL2/SDL_syswm.h>
# else
#  include <SDL/SDL.h>
#  include <SDL/SDL_syswm.h>
# endif
#else
# include "SDL.h"
# if !defined __APPLE__
#  include "SDL_syswm.h"
# endif
#endif


I did not have to remove this surrounding preprocessor check.

Can someone please help me to figure out what is happening here? If the symbol is defined both places should work, and if it is undefined it should fail on line 15 already, not on line 63. What is the point of this preprocessor symbol? The fact that eDuke compiles fine with this out of the way indicates to me that all my dependencies are set up correctly (the SDL Mixer header is located under `$C_INCLUDE_PATH/SDL/SDL_mixer.h`).

My system is Kubuntu 18.04. The full build log:
eduke32_20190202-7326$ make
Built object obj/duke3d/game.o 
Built object obj/duke3d/global.o 
Built object obj/duke3d/actors.o 
Built object obj/duke3d/gamedef.o 
Built object obj/duke3d/gameexec.o 
Built object obj/duke3d/gamevars.o 
Built object obj/duke3d/player.o 
Built object obj/duke3d/premap.o 
Built object obj/duke3d/sector.o 
Built object obj/duke3d/anim.o 
Built object obj/duke3d/common.o 
Built object obj/duke3d/config.o 
Built object obj/duke3d/demo.o 
Built object obj/duke3d/input.o 
Built object obj/duke3d/menus.o 
Built object obj/duke3d/namesdyn.o 
Built object obj/duke3d/net.o 
Built object obj/duke3d/savegame.o 
Built object obj/duke3d/rts.o 
Built object obj/duke3d/osdfuncs.o 
Built object obj/duke3d/osdcmds.o 
Built object obj/duke3d/grpscan.o 
Built object obj/duke3d/sounds.o 
Built object obj/duke3d/soundsdyn.o 
Built object obj/duke3d/cheats.o 
Built object obj/duke3d/sbar.o 
Built object obj/duke3d/screentext.o 
Built object obj/duke3d/screens.o 
Built object obj/duke3d/cmdline.o 
Built object obj/duke3d/startgtk.game.o 
Built object obj/duke3d/game_icon.o 
Built object obj/duke3d/game_banner.o 
Built object obj/build/rev.o 
Built object obj/build/baselayer.o 
Built object obj/build/cache1d.o 
Built object obj/build/klzw.o 
Built object obj/build/common.o 
Built object obj/build/compat.o 
Built object obj/build/crc32.o 
Built object obj/build/defs.o 
Built object obj/build/engine.o 
Built object obj/build/tiles.o 
Built object obj/build/clip.o 
Built object obj/build/2d.o 
Built object obj/build/hash.o 
Built object obj/build/palette.o 
Built object obj/build/polymost.o 
Built object obj/build/texcache.o 
Built object obj/build/dxtfilter.o 
Built object obj/build/hightile.o 
Built object obj/build/textfont.o 
Built object obj/build/smalltextfont.o 
Built object obj/build/kplib.o 
Built object obj/build/lz4.o 
Built object obj/build/osd.o 
Built object obj/build/pragmas.o 
Built object obj/build/scriptfile.o 
Built object obj/build/softsurface.o 
Built object obj/build/mmulti_null.o 
Built object obj/build/mutex.o 
Built object obj/build/xxhash.o 
Built object obj/build/md4.o 
Built object obj/build/colmatch.o 
Built object obj/build/screenshot.o 
Built object obj/build/mhk.o 
Built object obj/build/pngwrite.o 
Built object obj/build/miniz.o 
Built object obj/build/miniz_tinfl.o 
Built object obj/build/miniz_tdef.o 
Built object obj/build/fix16.o 
Built object obj/build/fix16_str.o 
Built object obj/build/a-c.o 
Built object obj/build/glsurface.o 
Built object obj/build/voxmodel.o 
Built object obj/build/mdsprite.o 
Built object obj/build/tilepacker.o 
Built object obj/build/glbuild.o 
Built object obj/build/polymer.o 
Built object obj/build/sdlayer.o 
Built object obj/build/gtkbits.o 
Built object obj/build/dynamicgtk.o 
Built object obj/build/animvpx.o 
In file included from source/build/include/mutex.h:10:0,
                 from source/build/include/osd.h:12,
                 from source/build/include/baselayer.h:11,
                 from source/duke3d/src/duke3d.h:28,
                 from source/duke3d/src/sdlmusic.cpp:35:
source/build/include/sdl_inc.h:63:25: fatal error: SDL_mixer.h: No such file or directory
compilation terminated.
Failed building obj/duke3d/sdlmusic.o from source/duke3d/src/sdlmusic.cpp!
make: *** [GNUmakefile:982: obj/duke3d/sdlmusic.o] Error 1

1

User is offline   Hendricks266 

  • Weaponized Autism

  #2

The Makefile is supposed to add this define:

ifeq ($(RENDERTYPE),SDL)
    ifeq ($(SDL_TARGET),2)
        SDLCONFIG := sdl2-config
        SDLNAME := SDL2
    else ifeq ($(SDL_TARGET),1)
        SDLCONFIG := sdl-config
        SDLNAME := SDL
        ifeq (0,$(RELEASE))
            COMPILERFLAGS += -DNOSDLPARACHUTE
        endif
    endif

    # ...

    ifneq ($(strip $(SDLCONFIG)),)
        ifeq ($(strip $(shell $(SDLCONFIG) --version $(DONT_PRINT_STDERR))),)
            override SDLCONFIG :=
        endif
    endif

    COMPILERFLAGS += -DSDL_TARGET=$(SDL_TARGET)

    SDL_FRAMEWORK := 0
    ifneq ($(SDL_FRAMEWORK),0)
        ifeq ($(PLATFORM),DARWIN)
            # ...
        endif
    else
        ifeq ($(MIXERTYPE),SDL)
            LIBS += -l$(SDLNAME)_mixer
        endif
        ifneq ($(SDLCONFIG),)
            SDLCONFIG_CFLAGS := $(strip $(subst -Dmain=SDL_main,,$(shell $(SDLCONFIG) --cflags)))
            SDLCONFIG_LIBS := $(strip $(subst -mwindows,,$(shell $(SDLCONFIG) --libs)))

            COMPILERFLAGS += $(SDLCONFIG_CFLAGS)
            LIBS += $(SDLCONFIG_LIBS)
        else
            ifeq ($(SDL_TARGET),1)
                COMPILERFLAGS += -D_GNU_SOURCE=1
            endif
            COMPILERFLAGS += -D_REENTRANT -DSDL_USEFOLDER
            LIBS += -l$(SDLNAME)
        endif
    endif
endif

0

User is offline   HiPhish 

#3

View PostHendricks266, on 16 February 2019 - 12:40 PM, said:

The Makefile is supposed to add this define:
...

Right, I can read that portion, but I do not understand its meaning. From what I can tell, `SDL_USEFOLDER` is defined only if `SDL_FRAMEWORK` is not zero and `SDLCONFIG` is empty.

Should `sdl2-config --cflags` produce `-DSDL_USEFOLDER` in its output? Because that is not what I'm getting:
duke32_20190202-7326$ sdl2-config --cflags
-I/gnu/store/4bhz5xzr39v0kgxf3ipv6kswicrdmkk4-sdl2-2.0.9/include/SDL2 -D_REENTRANT

(the weird file path is because of Guix, my package manager)

I can manually force the definition of this preprocessor symbol by invoking make as
make CUSTOMOPT=-DSDL_USEFOLDER

but is this how it is supposed to be?
1

User is offline   Hendricks266 

  • Weaponized Autism

  #4

If sdl2-config is able to run, SDL_USEFOLDER should not be defined. This is because `-I/gnu/store/4bhz5xzr39v0kgxf3ipv6kswicrdmkk4-sdl2-2.0.9/include/SDL2` should have SDL2.h directly in it, without needing to specify the folder name from cpp. What's interesting is that your build fails on SDL_mixer, not on SDL. I'm guessing Guix stores SDL_mixer in a separate path from SDL, but there does not look to be any SDL_mixer config script. Maybe Guix needs to patch their sdl2-config distribution to detect and include SDL sub-projects when installed.

If you `make SDLCONFIG=""` so that SDL_USEFOLDER is defined instead of running sdl2-config, I think you should be able to compile.
0

User is offline   HiPhish 

#5

View PostHendricks266, on 16 February 2019 - 01:32 PM, said:

If sdl2-config is able to run, SDL_USEFOLDER should not be defined.

Right, it is not defined, that is what I don't understand. If we look back at the first post, the offending piece of code is:
# if defined SDL_USEFOLDER
#  if SDL_TARGET == 2
#   include <SDL2/SDL_mixer.h>
#  else
#   include <SDL/SDL_mixer.h>
#  endif
# else
#  include "SDL_mixer.h"
# endif

Meaning: if SDL_USEFOLDER is not defined, search of the SDL_mixer.h file in the current directory (hence quotes around the file name), if it is defined search for it in one of the included directories (hence angle brackets around the file name). Maybe I'm missing the obvious here, but shouldn't it be the other way around?

View PostHendricks266, on 16 February 2019 - 01:32 PM, said:

This is because `-I/gnu/store/4bhz5xzr39v0kgxf3ipv6kswicrdmkk4-sdl2-2.0.9/include/SDL2` should have SDL2.h directly in it, without needing to specify the folder name from cpp. What's interesting is that your build fails on SDL_mixer, not on SDL. I'm guessing Guix stores SDL_mixer in a separate path from SDL, but there does not look to be any SDL_mixer config script.

No, all header files are under $C_INCLUDE_PATH/SDL2/, including SDL_mixer.h (sorry for the typo in the OP, I meant SDL2 of course).
1

User is offline   Hendricks266 

  • Weaponized Autism

  #6

View PostHiPhish, on 16 February 2019 - 01:41 PM, said:

Meaning: if SDL_USEFOLDER is not defined, search of the SDL_mixer.h file in the current directory (hence quotes around the file name), if it is defined search for it in one of the included directories (hence angle brackets around the file name). Maybe I'm missing the obvious here, but shouldn't it be the other way around?

I'm not sure quotes vs. angle brackets will matter in practice here. If you change `"SDL_mixer.h"` to `<SDL_mixer.h>` is there any difference?

View PostHiPhish, on 16 February 2019 - 01:41 PM, said:

No, all header files are under $C_INCLUDE_PATH/SDL2/, including SDL_mixer.h (sorry for the typo in the OP, I meant SDL2 of course).

Hmm. So is sdl2-config returning a misleading path?
0

User is offline   HiPhish 

#7

View PostHendricks266, on 16 February 2019 - 01:44 PM, said:

I'm not sure quotes vs. angle brackets will matter in practice here. If you change `"SDL_mixer.h"` to `<SDL_mixer.h>` is there any difference?

You are right, I just checked in my copy of K&R C, if the file name is in quotes and it is not found relative to the source file, the compiler will look for it in one of the default locations. I did not remember that detail, interesting.

View PostHendricks266, on 16 February 2019 - 01:44 PM, said:

Hmm. So is sdl2-config returning a misleading path?

Thank you, I'm an idiot for missing this. C_INCLUDE_PATH is a different directory than what is returned by sdl2-config, and the path from sdl2-config is missing exactly the SDL2_mixer.h header file.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options