1

I've an error probably due to SDL but I can't find it.

I tried to force the link between SDL2 and my compiler, and to check all characters to avoid a special one which isn't on any libraries. I have all the files required in the same directory.

#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_image.h>


//Function with picture display

//Function with text creation and text display

//Here I create an array of transparent pictures to do a Connect 4

//Here it's the thing that always appear in my window

//Here are the button of my main menu

//After all those function there's my main

It just doesn't compile with this text of error : 

    mbp-de-clement:Test grille clementdubois$ make clean; make; ./test_grille

    rm -f test_grille

    rm -f *.o

    gcc     test_grille.c   -o test_grille

    Undefined symbols for architecture x86_64:

      "_IMG_Load", referenced from:

          _main in test_grille-b3d516.o

    ... (lot of errors due to SDL) ...


    ld: symbol(s) not found for architecture x86_64

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    make: *** [test_grille] Error 1

    bash: ./test_grille: No such file or directory

I check all the posts on this site but can't find any help. I try to change my Makefile but nothing worked. I'm in desperate need of help for this project. 
  • Just so you know, you're actually using `clang` on your mac, not `gcc`. Apple aliased the command. – Christian Gibbons Apr 17 '19 at 18:35
  • Oh so it could be the error ? Do you want to see my Makefile ? – Clément Dubois Apr 17 '19 at 18:37
  • `gcc test_grille.c -o test_grille` isn't linking against SDL2 at all. you probably need `-lSDL2 -lSDLImage2` or something – Jean-François Fabre Apr 17 '19 at 18:37
  • ``` CC=gcc FLAGS = -Wall -g SDL_DIR=${HOME}/SDL2 SDLLIB_DIR=${SDL_DIR}/lib SDLINC_DIR=${SDL_DIR}/include LIBS=-L${SDLLIB_DIR} -lSDL2 -lSDL2_ttf -lSDL2_image INCLUDES=-I${SDLINC_DIR} PROG=test_grille all: test_grille test_sdl: test_grille.c ${CC} $^ -o $@ ${LIBS} ${INCLUDES} ${FLAGS} clean: rm -f ${PROG} rm -f *.o ``` – Clément Dubois Apr 17 '19 at 18:39
  • No, using `clang` is probably not a problem. The two compilers are usually pretty interchangeable. Just thought you might be interested to know which compiler you're actually using as it may be worth knowing for you in the future. – Christian Gibbons Apr 17 '19 at 18:40
  • I do use it !But maybe the Makefile isn't good Oh yes ok thanks for this info ! :) – Clément Dubois Apr 17 '19 at 18:40

0 Answers0