Statically including SDL libraries into makefile

  • I just have finished my summer project with using SDL libraries.But there is a problem about submission.
  • How can i include my libraries which are SDL_2.0 , SDL_image , SDL_ttf , SDL_mixer to my makefile without installing on my computer ?
  • I have all of them seperately as a file.

Makefile:

# A simple Makefile for compiling small SDL projects

# set the compiler

CC := gcc

# set the compiler flags

CFLAGS := `sdl2-config --libs --cflags` -ggdb3 -O0 --std=c99 -Wall -lSDL2_mixer -lSDL2_ttf -lm

LDFLAGS= -L /lib -l SDL2_image-2.0.5

# add header files here

HDRS := structs.h common.h main.h init.h defs.h input.h drawIssue.h texture.h stage.h map.h fileOperation.h camera.h move.h check.h

# add source files here

SRCS := main.c init.c input.c drawIssue.c texture.c stage.c map.c fileOperation.c camera.c move.c check.c

# generate names of object files

OBJS := $(SRCS:.c=.o)

# name of executable

EXEC := game

# default recipe

all: $(EXEC)

showfont: showfont.c Makefile

$(CC) -o $@ $@.c $(CFLAGS) $(LIBS)

glfont: glfont.c Makefile

$(CC) -o $@ $@.c $(CFLAGS) $(LIBS)

# recipe for building the final executable

$(EXEC): $(OBJS) $(HDRS) Makefile

$(CC) -o $@ $(OBJS) $(CFLAGS)

# recipe for building object files

#$(OBJS): $(@:.o=.c) $(HDRS) Makefile

# $(CC) -o $@ $(@:.o=.c) -c $(CFLAGS)

# recipe to clean the workspace

clean:

rm -f $(EXEC) $(OBJS)

.PHONY: all clean

I tried to use :

LDFLAGS= -L /lib -l SDL2_image-2.0.5

for including SDL_image file.It did not work :(.

What changes should be ?

1 Like