LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   unable to compile - #include <SDL.h> (https://www.linuxquestions.org/questions/linux-software-2/unable-to-compile-include-sdl-h-4175643486/)

sirius57 12-01-2018 08:55 PM

unable to compile - #include <SDL.h>
 
Hello,

I have the following error when compiling defendguin:

make
make: sdl-config: Command not found
make: sdl-config: Command not found
cc -Wall -DDATA_PREFIX="/usr/local/share/defendguin/" -D__SOUND -DJOY_YES src/defendguin.c -c -o obj/defendguin.o
src/defendguin.c:25:17: fatal error: SDL.h: No such file or directory
#include <SDL.h>
^
compilation terminated.
make: *** [obj/defendguin.o] Error 1

I have libSDL packages installed

Opensuse 13.1 64bit os

BW-userx 12-01-2018 09:00 PM

look (install) for your developer headers, libSDL-dev or libSDL-devel or how ever your distro names them.

YesItsMe 12-02-2018 07:53 AM

On openSUSE, it's libSDL-devel.

BW-userx 12-02-2018 02:39 PM

yes, most distros make it whatever they want.

sirius57 12-12-2018 08:29 PM

Thanks, I solved that problem, now the compiler complains about not finding SDL_mixer.h

make
cc -Wall -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DDATA_PREFIX="/usr/local/share/defendguin/" -D__SOUND -DJOY_YES src/defendguin.c -c -o obj/defendguin.o
src/defendguin.c:28:23: fatal error: SDL_mixer.h: No such file or directory
#include <SDL_mixer.h>
^
compilation terminated.
make: *** [obj/defendguin.o] Error 1

BW-userx 12-12-2018 08:49 PM

here is something on your distro and this issue?
https://forums.opensuse.org/showthre...to-on-openSUSE

sirius57 12-13-2018 08:05 PM

After searching my system, I have libsdl_mixer-1_2-0 installed, however, I can not find it. I have what appears to be all the sdl and sdl mixer files. The sdl folder I can find, but I can not find the mixer folder or the sdl mixer header file. If libsdl_mixer is listed, then it is installed. How do I include the mixer when doing the compile?

BW-userx 12-13-2018 09:04 PM

What application are you trying to compile?

That page I linked suggest using
Code:

pkg-config --cflags SDL2

so it might be something like
g++ file.c pkg-config --cflags SDL2 -o app name

adding what else you use in that line as well. what is your make file?

sirius57 12-16-2018 07:03 PM

If I understand what the code in your post refers to, that I have to associate the compiler with the mixer? I am trying to compile Defendguin.
Listed below is the make file:

# Makefile for defendguin

# by Bill Kendrick
# bill@newbreedsoftware.com
# http://www.newbreedsoftware.com/defendguin/

# November 6, 1999 - January 29, 2006


# User-definable stuff:

CFLAGS=-Wall -O2
#DATA_PREFIX=$(PWD)/data/
PREFIX=/usr/local
MAN_PREFIX=$(PREFIX)
BIN_PREFIX=$(PREFIX)/bin
DATA_PREFIX=$(PREFIX)/share/defendguin/
JOY=YES


# Other definitions:

SDL_CFLAGS := $(shell sdl-config --cflags)
SDL_LDFLAGS := $(shell sdl-config --libs) -L/usr/X11R6/lib
MIXER=-lSDL_mixer
NOSOUNDFLAG=__SOUND
CFLAGS=-Wall $(SDL_CFLAGS) -DDATA_PREFIX="$(DATA_PREFIX)" -D$(NOSOUNDFLAG) \
-DJOY_$(JOY)
SDL_LIB=$(SDL_LDFLAGS) $(MIXER)


# Make commands:

all: defendguin

nosound:
make defendguin MIXER= NOSOUNDFLAG=NOSOUND

install: defendguin
install -d $(DATA_PREFIX)
cp -R data/* $(DATA_PREFIX)
chmod -R a+rX,g-w,o-w $(DATA_PREFIX)
cp defendguin $(BIN_PREFIX)/
chmod a+rx,g-w,o-w $(BIN_PREFIX)/defendguin
-mkdir -p $(MAN_PREFIX)/man/man6/
cp src/defendguin.6 $(MAN_PREFIX)/man/man6/
chmod a+rx,g-w,o-w $(MAN_PREFIX)/man/man6/defendguin.6

uninstall:
-rm -r $(DATA_PREFIX)
-rm $(PREFIX)/bin/defendguin
-rm $(PREFIX)/man/man6/defendguin.6

clean:
-rm defendguin
-rm obj/*.o


# Main executable:

defendguin: obj/defendguin.o
$(CC) $(CFLAGS) obj/defendguin.o -o defendguin $(SDL_LIB) -lm


# Main object:

obj/defendguin.o: src/defendguin.c
$(CC) $(CFLAGS) src/defendguin.c -c -o obj/defendguin.o

BW-userx 12-16-2018 07:57 PM

let me run that on my system as see if I can figire it out for you.

I just issued 'make' bamn done.

you installed you SDL devel here
https://software.opensuse.org/package/libSDL-1_2-0

do a find for the files it says it cannot find,
Code:

find / -type f -iname xxx
using iname for no case senitive search, if you cannot find them, then do a wild card search for the files, they maybe under a name that is not exectly like it is looking for. If so, then just hack your code to make them match what you have on your system. that is what I'd do.

It is only one c file in your source to modify.
Code:

#include <SDL.h>

#ifndef NOSOUND
#include <SDL_mixer.h>
#endif /* #ifndef NOSOUND */

in the doc/INSTALL.txt
Code:

Note: If you do not have the SDL_mixer library, or wish to not
    compile sound support into the game, you can compile it like this:

        make nosound

I suggest you read INSTALL.txt and README.txt

ondoho 12-17-2018 01:52 AM

Quote:

Originally Posted by sirius57 (Post 5937946)

glad if you manage to compile it!
but i just wanted to mention that the last time this package received any sort of update was 2009. a LOT has changed since then. compilers, libraries...
there's also a precompiled version, maybe it works?


All times are GMT -5. The time now is 06:39 PM.