gcc : Compilation SDL [Réglé]
référence indéfinie vers « IMG_Load »
Logiciels / Programmation

Troumad Membre non connecté
-
- Voir le profil du membre Troumad
- Inscrit le : 16/10/2010
- Site internet
- Groupes :
Est-ce que certains d'entre vous programme en utilisant la bibliothèque SDL ?
Je viens de faire le test avec mageia7, mageia8 et mageia9. J'ai le même problème dans les trois environnements.
Lors de la création de liens, il manque des bibliothèques :
Code :
[troumad@localhost area_erisi2]$ make
gcc -o area couleur.o main.o -export-dynamic -L/usr/lib64 -lSDL
/usr/bin/ld : main.o : dans la fonction « main » :
main.c:(.text+0x92) : référence indéfinie vers « IMG_Load »
/usr/bin/ld : main.c:(.text+0x160) : référence indéfinie vers « TTF_Init »
/usr/bin/ld : main.o : dans la fonction « affiche_nombre » :
main.c:(.text+0xcfd) : référence indéfinie vers « TTF_OpenFont »
/usr/bin/ld : main.c:(.text+0xd10) : référence indéfinie vers « TTF_OpenFont »
/usr/bin/ld : main.c:(.text+0xd50) : référence indéfinie vers « TTF_RenderUTF8_Solid »
/usr/bin/ld : main.c:(.text+0xdb1) : référence indéfinie vers « TTF_RenderUTF8_Solid »
collect2: erreur: ld a retourné le statut de sortie 1
make: *** [makefile:17 : area] Erreur 1
Pourtant, elles y sont :
Code :
[troumad@localhost SDL_etu]$ ll /usr/lib64/libSDL_*
lrwxrwxrwx 1 root root 20 févr. 14 2020 /usr/lib64/libSDL_gfx.so -> libSDL_gfx.so.16.9.1*
lrwxrwxrwx 1 root root 20 févr. 14 2020 /usr/lib64/libSDL_gfx.so.16 -> libSDL_gfx.so.16.9.1*
-rwxr-xr-x 1 root root 92816 févr. 14 2020 /usr/lib64/libSDL_gfx.so.16.9.1*
lrwxrwxrwx 1 root root 25 févr. 18 2020 /usr/lib64/libSDL_image-1.2.so.0 -> libSDL_image-1.2.so.0.8.4*
-rwxr-xr-x 1 root root 65632 févr. 18 2020 /usr/lib64/libSDL_image-1.2.so.0.8.4*
lrwxrwxrwx 1 root root 25 févr. 18 2020 /usr/lib64/libSDL_image.so -> libSDL_image-1.2.so.0.8.4*
lrwxrwxrwx 1 root root 26 nov. 3 19:57 /usr/lib64/libSDL_mixer-1.2.so.0 -> libSDL_mixer-1.2.so.0.12.0*
-rwxr-xr-x 1 root root 178312 nov. 3 19:57 /usr/lib64/libSDL_mixer-1.2.so.0.12.0*
lrwxrwxrwx 1 root root 26 nov. 3 19:57 /usr/lib64/libSDL_mixer.so -> libSDL_mixer-1.2.so.0.12.0*
lrwxrwxrwx 1 root root 23 févr. 14 2020 /usr/lib64/libSDL_net-1.2.so.0 -> libSDL_net-1.2.so.0.8.0*
-rwxr-xr-x 1 root root 24024 févr. 14 2020 /usr/lib64/libSDL_net-1.2.so.0.8.0*
lrwxrwxrwx 1 root root 23 févr. 14 2020 /usr/lib64/libSDL_net.so -> libSDL_net-1.2.so.0.8.0*
lrwxrwxrwx 1 root root 21 févr. 14 2020 /usr/lib64/libSDL_Pango.so -> libSDL_Pango.so.1.1.0*
lrwxrwxrwx 1 root root 21 févr. 14 2020 /usr/lib64/libSDL_Pango.so.1 -> libSDL_Pango.so.1.1.0*
-rwxr-xr-x 1 root root 23880 févr. 14 2020 /usr/lib64/libSDL_Pango.so.1.1.0*
lrwxrwxrwx 1 root root 25 avril 20 2020 /usr/lib64/libSDL_sound-1.0.so.1 -> libSDL_sound-1.0.so.1.0.2*
-rwxr-xr-x 1 root root 179432 avril 20 2020 /usr/lib64/libSDL_sound-1.0.so.1.0.2*
lrwxrwxrwx 1 root root 25 avril 20 2020 /usr/lib64/libSDL_sound.so -> libSDL_sound-1.0.so.1.0.2*
lrwxrwxrwx 1 root root 24 févr. 14 2020 /usr/lib64/libSDL_ttf-2.0.so.0 -> libSDL_ttf-2.0.so.0.10.1*
-rwxr-xr-x 1 root root 32272 févr. 14 2020 /usr/lib64/libSDL_ttf-2.0.so.0.10.1*
lrwxrwxrwx 1 root root 24 févr. 14 2020 /usr/lib64/libSDL_ttf.so -> libSDL_ttf-2.0.so.0.10.1*
Pour information, ce sont des programmes que j'ai fait et tester il y a une dizaine d'années. Ils marchaient bien à l'époque. Maintenant, je compte à nouveau regarder SDL. Mais, ça plante :(
Édité par Troumad Le 06/04/2021 à 09h49
Amicalement Votre
Bernard SIAUD Alias Troumad
Bernard SIAUD Alias Troumad

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
Code TEXT :
urpmf libSDL_ttf lib64SDL_ttf-devel:/usr/lib64/libSDL_ttf.so
Aller hop :
Code BASH :
urpmi lib64SDL_ttf-devel

Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |

Troumad Membre non connecté
-
- Voir le profil du membre Troumad
- Inscrit le : 16/10/2010
- Site internet
- Groupes :
Code :
Le paquetage lib64SDL_ttf-devel-2.0.11-11.mga8.x86_64 est déjà installé
Le fichier utile est listé dans lib64.
Le même makefile avec un code SDL qui n'utilise ni IMG_Load, ni TTF_Init compile bien.
Édité par Troumad Le 06/04/2021 à 09h55
Amicalement Votre
Bernard SIAUD Alias Troumad
Bernard SIAUD Alias Troumad

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
Code TEXT :
-lSDL2 -lSDL2_ttf -lSDL2_image
?
(je dis ça, j'en sais rien, je sais juste que ce sont des .so différents, et qu'il y a la version 2 et la version 1.2.)
Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |

funix Membre non connecté
-
- Voir le profil du membre funix
- Inscrit le : 17/12/2012
- Site internet
- Groupes :

Troumad Membre non connecté
-
- Voir le profil du membre Troumad
- Inscrit le : 16/10/2010
- Site internet
- Groupes :
Code :
CFLAGS= -W -Wall $(shell sdl-config --cflags)
LDFLAGS=-export-dynamic $(shell sdl-config --libs)
#LDFLAGS=$(shell sdl-config --libs)
EXEC=area
SRC= $(wildcard *.c)
OBJ= $(SRC:.c=.o)
all: $(EXEC)
$(EXEC) : $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
%.o: %.c include.h
$(CC) -o $@ -c $< $(CFLAGS)
SDL2 me pose problème avec SDL_HWSURFACE et SDL_DOUBLEBUF
Amicalement Votre
Bernard SIAUD Alias Troumad
Bernard SIAUD Alias Troumad

Troumad Membre non connecté
-
- Voir le profil du membre Troumad
- Inscrit le : 16/10/2010
- Site internet
- Groupes :
funix :
et si tu rajoutes -lSDL_image à ta ligne gcc ?
Ça marche ! Merci

Ça veut dire que le sdl-config --libs ne marche plus comme avant ? Pourquoi ne rajoute-t-il pas tout ce qu'il faut ? Il sert à quoi alors ?
Code :
LDFLAGS=-export-dynamic $(shell sdl-config --libs) -lSDL_image -lSDL_ttf
Édité par Troumad Le 06/04/2021 à 10h10
Amicalement Votre
Bernard SIAUD Alias Troumad
Bernard SIAUD Alias Troumad

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
Code TEXT :
$(sdl-config --libs) -lSDL_image
est présenté.
Je pense que sdl-config sert surtout à ajouter -L/usr/lib64 qui peut varier d'une installation à une autre.
Je dirais, qu'avant, tu avais de la chance que ça se compile (ou plutôt, surement que gcc était plus permissif).
Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie