IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SDL Discussion :

cannot find -lSDL.dll et undefined reference to `SDL_Init' [SDL 1.2]


Sujet :

SDL

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre très actif Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 23
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Par défaut cannot find -lSDL.dll et undefined reference to `SDL_Init'
    bonjour,
    j'essaye de faire une programme de fractale mandelbrot
    J'ai d’abord créé un sujet où j'ai fini par avoir beaucoup de problemes
    mon programme me met donc
    main.cpp:120: undefined reference to `SDL_Init'
    main.cpp:125: undefined reference to `SDL_SetVideoMode'
    main.cpp:126: undefined reference to `SDL_WM_SetCaption'
    main.cpp:128: undefined reference to `SDL_RWFromFile'
    main.cpp:128: undefined reference to `SDL_LoadBMP_RW'
    main.cpp:129: undefined reference to `SDL_UpperBlit'
    main.cpp:132: undefined reference to `SDL_EnableKeyRepeat'
    main.cpp:135: undefined reference to `SDL_WaitEvent'
    main.cpp:148: undefined reference to `SDL_RWFromFile'
    main.cpp:148: undefined reference to `SDL_SaveBMP_RW'
    main.cpp:218: undefined reference to `SDL_Quit'
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    #include <SDL/SDL.h>
    #include <algorithm>
    using namespace std;
    int pycode(int c_1,int c_2,int c_3)
    {
        return c_3+c_2*256+c_1*256*256;
    }
    void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel,int nbOctetsParPixel)
    {
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
        switch(nbOctetsParPixel)
        {
            case 1:
                *p = pixel;
                break;
            case 2:
                *(Uint16 *)p = pixel;
                break;
            case 3:
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                {
                    p[0] = (pixel >> 16) & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = pixel & 0xff;
                }
                else
                {
                    p[0] = pixel & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = (pixel >> 16) & 0xff;
                }
                break;
            case 4:
                *(Uint32 *)p = pixel;
                break;
        }
    }
    Uint32 lirePixel(SDL_Surface *surface, int x, int y,int nbOctetsParPixel)
    {
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
        switch(nbOctetsParPixel)
        {
            case 1:
                return *p;
            case 2:
                return *(Uint16 *)p;
            case 3:
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                    return p[0] << 16 | p[1] << 8 | p[2];
                else
                    return p[0] | p[1] << 8 | p[2] << 16;
            case 4:
                return *(Uint32 *)p;
            default:
                return 0;
        }
    }
    void decale(SDL_Surface *ecran,int x,int y,int nbOctetsParPixel)
    {
        Uint32 temp[480][600];
        for(int i=max(0,x);i<min(600,600+x);i++)
        {
            for(int j=max(0,y);j<min(480,480+y);j++)
            {
                temp[j][i]=lirePixel(ecran,i,j,nbOctetsParPixel);
            }
        }
        for(int i=max(0,x);i<min(600,600+x);i++)
        {
            for(int j=max(0,y);j<min(480,480+y);j++)
            {
                definirPixel(ecran,i-x,j-y,temp[j][i],nbOctetsParPixel);
            }
        }
    }
    int main(int argc, char *argv[])
    {
        int tx1=0,ty1=0;
        int tx2=0;
        int ty2=0;
        int ri=250;
        int vi=0;
        int bi=0;
        int i;
        int couleur[150];
        for (i=0;i<25;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi+=10;
        }
        for (;i<50;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri-=10;
        }
        for (;i<75;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi+=10;
        }
        for (;i<100;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi-=10;
        }
        for (;i<125;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri+=10;
        }
        for (;i<150;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi-=10;
        }
        double xa=0,ya=0;
        SDL_Event event;
        int continuer = 1;
        int tempsPrecedent = 0, tempsActuel = 0;
        SDL_Init(SDL_INIT_VIDEO);
        SDL_Surface *ecran =NULL,*Fond = NULL;
        SDL_Rect positionFond;
        positionFond.x = 0;
        positionFond.y = 0;
        ecran = SDL_SetVideoMode(600, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
        SDL_WM_SetCaption("Mandelbrot", NULL);
        int nbOctetsParPixel = ecran->format->BytesPerPixel;
        Fond = SDL_LoadBMP("debut.bmp");
        SDL_BlitSurface(Fond, NULL, ecran, &positionFond);
        int iteration_max=150;
        double zoom=200;
        SDL_EnableKeyRepeat(400,200);
        while (continuer)
        {
            SDL_WaitEvent(&event);
            switch(event.type)
            {
                case SDL_QUIT:
                    continuer = 0;
                    break;
                case SDL_KEYDOWN:
                    switch (event.key.keysym.sym)
                    {
                        case SDLK_u:
                            iteration_max+=50;
                            break;
                        case SDLK_t:
                            SDL_SaveBMP(ecran,"mandelbrot.bmp");
                            break;
                        case SDLK_RALT:
                            zoom/=1.5;
                            break;
                        case SDLK_r:
                            zoom=200;
                            break;
                        case SDLK_LEFT:
                            xa-=50/zoom;
                            tx2=550;
                            decale(ecran,-50,0,nbOctetsParPixel);
                            break;
                        case SDLK_RIGHT:
                            xa+=50/zoom;
                            tx1=550;
                            decale(ecran,50,0,nbOctetsParPixel);
                            break;
                        case SDLK_UP:
                            ya-=50/zoom;
                            ty2=430;
                            decale(ecran,0,-50,nbOctetsParPixel);
                            break;
                        case SDLK_DOWN:
                            ya+=50/zoom;
                            ty1=430;
                            decale(ecran,0,50,nbOctetsParPixel);
                            break;
                        case SDLK_SPACE:
                            zoom*=1.5;
                            break;
                        case SDLK_BACKSPACE:
                            iteration_max+=20;
                            break;
                        case SDLK_e:
                            iteration_max-=50;
                            break;
                    }
                    long double eca=zoom/200;
                    long double x1 =xa-1.5/eca;
                    long double x2 =xa+1.5/eca;
                    long double y1 =ya-1.2/eca;
                    long double y2 =ya+1.2/eca;
                    #pragma omp parallel for schedule(dynamic, 1)
                    for(int x=tx1;x<600-tx2;x++)
                    {
                        for(int y=ty1;y<480-ty2;y++)
                        {
                            long double c_r = x / zoom + x1,c_i = y / zoom + y1,z_r = 0,z_i = 0;
                            int i = 0;
                            while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                            {
                                long double tmp = z_r;
                                z_r = z_r*z_r - z_i*z_i + c_r;
                                z_i = 2*z_i*tmp + c_i;
                                i++;
                            }
                            if (i < iteration_max)
                                definirPixel(ecran,x,y,couleur[i%150],nbOctetsParPixel);
                            else
                                definirPixel(ecran,x,y,0,nbOctetsParPixel);
                        }
                    }
                    tx1=0;
                    ty1=0;
                    tx2=0;
                    ty2=0;
            }
            SDL_Flip(ecran);
        }
        SDL_Quit();
        return EXIT_SUCCESS;
    }
    J'ai tout réinstallé(codeblocks,SDL),créé un nouveau projet et ça me met:
    ld.exe: cannot find -lSDL.dll
    ld.exe: cannot find -lSDLmain
    si quelqu’un peut m'aider,je lui en serai très reconnaissant
    merci

  2. #2
    Expert confirmé
    Avatar de Kannagi
    Homme Profil pro
    cyber-paléontologue
    Inscrit en
    Mai 2010
    Messages
    3 226
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cyber-paléontologue

    Informations forums :
    Inscription : Mai 2010
    Messages : 3 226
    Par défaut
    Ton probleme est explicite , t'as mal linker la SDL , c'est rare mais je vais me quoter :

    Citation Envoyé par Kannagi Voir le message
    Problème mainte et mainte fois résolu.

    Sur code::block :
    Build option-> Linker Setting ->Link Librairies : ->
    si cela ne marche pas tu dois installer ta librairie ou se trouve ton compilateur (dans ton cas probablement mingw).

    Si tu ne comprend pas ce que tu fait et que tu n'y arrive pas (et que j'ai la flemme de t'expliquer comment fonctionne la compilation en C , c'est pas ce qui manque sur le net ou sur le forum) tu peux faire un tour ici:
    http://jeux.developpez.com/telecharg.../709/Templates
    Et au cas ou tu sais pas lequel prendre , j’imagine que tu veux prendre la SDL 1.2 ? donc : http://jeux.developpez.com/telecharg...ur-Code-Blocks
    Note : je crois que les templates ont était créer explicitement pur ce genre d souci tellement qu'ils sont courant.

  3. #3
    Membre très actif Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 23
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Par défaut
    Merci beaucoup pour ta réponse mais malheureusement,même avec le template,il me met:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    x86_64-w64-mingw32-g++.exe -Llib -o bin\Debug\SDL_Template.exe obj\Debug\sources\main.o   -lmingw32 -lSDLmain -lSDL
    C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible lib/libSDLmain.a when searching for -lSDLmain
    C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible lib\libSDLmain.a when searching for -lSDLmain
    C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible lib/libSDLmain.a when searching for -lSDLmain
    C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDLmain
    C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible lib/libSDL.dll.a when searching for -lSDL
    C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible lib/libSDL.dll.a when searching for -lSDL
    C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL
    collect2.exe: error: ld returned 1 exit status
    Process terminated with status 1 (0 minute(s), 1 second(s))
    3 error(s), 0 warning(s) (0 minute(s), 1 second(s))
    pourtant,je n'ai touché a rien et laissé le code déjà présent dans le template

  4. #4
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 150
    Billets dans le blog
    150
    Par défaut
    Bonjour,

    Car vous avez installé MinGW en version 64 bits. Les templates ne sont prévus que pour des version 32 bits (c'est la configuration la plus répandue).
    Pour compiler votre projet, il faudra installer la version 64 bits de la SDL ... sauf que je n'ai pas souvenir que cela existe vraiment. Du coup, il faudrait mieux installer une version 32bits de MinGW.

    Lorsque le compilateur est incompatible avec les bibliothèques, il les voient, mais ne l'indique pas toujours (il ne fait que les ignorer, car il ne peut pas s'en servir). C'est ce qu'il dit avec le message "Skipping".
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  5. #5
    Membre très actif Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 23
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Par défaut
    et c'est parti pour reinstaller Code::Blocks!!!

  6. #6
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 150
    Billets dans le blog
    150
    Par défaut
    Bah ... oui (en bon trolleur, je rajouterai que c'est pour ça que je préfère Linux )
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. winsock.h : undefined reference...
    Par abraxas dans le forum Dev-C++
    Réponses: 14
    Dernier message: 06/08/2012, 13h42
  2. Impossible de compiler : /usr/bin/ld: cannot find -lSDL
    Par Heavy Metal Hero dans le forum Caml
    Réponses: 2
    Dernier message: 03/12/2011, 13h39
  3. undefined reference to `SDL_Init' projet C avec SDL
    Par marion5515 dans le forum Débuter
    Réponses: 2
    Dernier message: 21/05/2009, 13h19
  4. Réponses: 4
    Dernier message: 31/07/2007, 18h02
  5. Réponses: 17
    Dernier message: 25/10/2005, 10h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo