Problème makefile + librairie
Bonjour,
Voila mon probleme : Lorsque j'essaie de compiler mon projet SDL a l'aide de mon makefile cela me donne une suite de "undefine reference to.." ( pour chaque fonction SDL utilisé.
Voici mon makefile :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
DEBUG=yes
CC=gcc
LIBRARY_SDL=./lib/
INCLUDE_SDL=./include/
ifeq ($(DEBUG),yes)
CFLAGS:=-W -Wall -ansi -pedantic -g -I$(INCLUDE_SDL)
LDFLAGS:= -L$(LIBRARY_SDL) -lSDL -lSDLmain -lSDL_image
else
CFLAGS:=-W -Wall -ansi -pedantic -I$(INCLUDE_SDL)
LDFLAGS:= -L$(LIBRARY_SDL) -lSDL -lSDLmain -lSDL_image
endif
EXEC:=$(shell grep -l "int main" *.c | cut -d . -f 1)
SRC:=$(shell ls *.c)
OBJ:=$(SRC:.c=.o)
all: $(EXEC)
ifeq ($(DEBUG),yes)
@echo "Generation en mode debug"
else
@echo "Generation en mode release"
endif
main: $(OBJ)
@$(CC) -o $@ $^ $(LDFLAGS)
.SUFFIXES: .c
%.o: %.c
@$(CC) -o $@ -c $< $(CFLAGS)
depend:
makedepend -- $(CFLAGS) -- $(SRC)
.PHONY: clean mrproper
clean:
@rm -rf *.o *~
mrproper: clean
@rm -rf ${EXEC} |
comme vous pouvez le constater, a priori, l'edition de lien est presente...
Voici maintenant mon fichier source :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include <SDL_image.h>
int main(int argc, char *argv[])
{
int continuer=1;
SDL_Surface *ecran = NULL;
SDL_Event event;
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE);
SDL_WM_SetCaption("Gestion des évènements en SDL", NULL);
while (continuer){
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
continuer = 0;
break;
}
break;
}
}
SDL_Quit();
return EXIT_SUCCESS;
} |
et enfin, voici l'organisation de mon dossier de projet :
.:
include Makefile project1.c project3.c src
lib project2.c sdl-config
./include:
begin_code.h SDL_config.h SDL_image.h SDL_mutex.h SDL_syswm.h
close_code.h SDL_cpuinfo.h SDL_joystick.h SDL_name.h SDL_thread.h
SDL SDL_endian.h SDL_keyboard.h SDL_opengl.h SDL_timer.h
SDL_active.h SDL_error.h SDL_keysym.h SDL_platform.h SDL_types.h
SDL_audio.h SDL_events.h SDL_loadso.h SDL_quit.h SDL_version.h
SDL_byteorder.h SDL_getenv.h SDL_main.h SDL_rwops.h SDL_video.h
SDL_cdrom.h SDL.h SDL_mouse.h SDL_stdinc.h
./include/SDL:
begin_code.h SDL_cpuinfo.h SDL_joystick.h SDL_name.h SDL_thread.h
close_code.h SDL_endian.h SDL_keyboard.h SDL_opengl.h SDL_timer.h
SDL_active.h SDL_error.h SDL_keysym.h SDL_platform.h SDL_types.h
SDL_audio.h SDL_events.h SDL_loadso.h SDL_quit.h SDL_version.h
SDL_byteorder.h SDL_getenv.h SDL_main.h SDL_rwops.h SDL_video.h
SDL_cdrom.h SDL.h SDL_mouse.h SDL_stdinc.h
SDL_config.h SDL_image.h SDL_mutex.h SDL_syswm.h
./lib:
libSDL.a libSDL_image.la libSDL.la libSDL.so
libSDL_image.a libSDL_image.so libSDLmain.a pkgconfig
./lib/pkgconfig:
sdl.pc
Mon but etant de ne pas installer la librairie a proprement parler si possible dans le dossier /usr/lib (sous linux) et donc de travailler directement a partir des fichier present dans mon dossier.
Merci d'avance ^^