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

Code::Blocks Discussion :

SDL avec codeBlocks et MS VcToolkit 2003


Sujet :

Code::Blocks

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 15
    Points : 14
    Points
    14
    Par défaut SDL avec codeBlocks et MS VcToolkit 2003
    Bonjour,

    Je désire utiliser la librairie SDL via l'IDE codeBlocks avec le compilateur VC ToolKit 2003.
    Après de multiples essais, impossible d'utiliser la librairie (problèmes de linkage ou de paramétrage).

    Voici la description de mon install :

    I ] Les repertoires d'installation des composants :


    1 ) Codeblocks (sans MingGw) :

    path : C:\CodeBlocks

    2 ) VcToolkit 2003 :

    path : C:\VCToolkit2003

    3 ) .NET 1.1 SDK :

    path : C:\Program Files\Microsoft.NET\SDK\v1.1

    4 ) Platform SDK :

    path : C:\PlatformSDK

    5 ) DirectX SDK :

    path : C:\dxsdk

    II ] Les paramètres dans codeBlocks :

    1 ) Menu "Settings" > "compiler" > onglet "directories" > sous onglet "compiler" :

    - C:\VCToolkit2003\include
    - C:\PlatformSDK\Include
    - C:\Program Files\Microsoft.NET\SDK\v1.1\include
    - C:\dxsdk\Include

    1.1 ) Menu "Settings" > "compiler" > onglet "directories" > sous onglet "linker" :

    - C:\VCToolkit2003\lib
    - C:\Program Files\Microsoft.NET\SDK\v1.1\Lib
    - C:\PlatformSDK\Lib
    - C:\dxsdk\Lib

    2 ) Menu "Settings" > "compiler" > onglet "programs" :

    > compiler installation directory :
    path : C:\VCToolkit2003\

    2.1 ) Menu "Settings" > "compiler" > onglet "programs" > sous onglet "Program Files" :

    - c compiler : cl.exe (situé dans : C:\VCToolkit2003\bin)
    - c++ compiler : cl.exe (situé dans : C:\VCToolkit2003\bin)
    - linker for dynamic libs : link.exe (situé dans : C:\VCToolkit2003\bin)
    - linker for static libs : link.exe (situé dans : C:\VCToolkit2003\bin)
    - ressource compiler : RC.Exe (situé dans : C:\PlatformSDK\Bin)
    - Make Program : nmake.exe (situé dans : C:\PlatformSDK\Bin)

    2.1 ) Menu "Settings" > "compiler" > onglet "programs" > sous onglet "Other" :

    - compiler logging : Full command line
    - build method : Invoke compiler directly
    - Shell to run console programs : xterm -T $TITLE -e

    2.2 ) paramètres SDL :

    - fichiers ".h" : C:\VCToolkit2003\include\sdl\
    - fichier "SDL.lib" : C:\VCToolkit2003\lib\SDL.lib
    - fichier "SDLmain.lib" : C:\VCToolkit2003\lib\SDLmain.lib


    III ] Mon projet SDL


    1 ) Projet généré avec le template SDL de codeBlocks (avec creation automatique de fichier "main.cpp")

    2 ) Paramètres du projet :

    - Nom du projet : "sdlapp" (C:\projHuit\sdlapp.cbp)
    - répertoire du projet et des sources : C:\projHuit (contenant "SDL.dll")
    - Type : "GUI Apllication"
    - Output File name : "sdlapp.exe"
    - Execution Working Dir : "."
    - Objects Output Dir : ".objs" (situé dans : C:\projHuit)
    - Files : "main.cpp" (situé dans : C:\projHuit), "cb.bmp" (situé dans : C:\projHuit)

    2.1 ) Target Build Options :

    - selected compiler : Microsoft Visual C++ 2003
    - policy : "append target options to project options"
    - onglet "compiler flags" : "disable optimisation" coché uniquement
    - policy : "append target options to project options"
    - onglet "linker" > "link libraries" : "SDL" & "SDLmain"
    - policy : "append target options to project options"
    - onglet "directories" > "compiler" : policy : "append target options to project options"
    - onglet "directories" > "linker" > : policy : "append target options to project options"
    - onglet "directories" > "ressource compiler" > : policy : "use project options only"
    - onglet "commands" et "custom variables" : vides


    IV ] Le fichier "main.cpp" généré par codeBlocks (code complet) :


    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
     
    #ifdef __cplusplus
        #include <cstdlib>
    #else
        #include <stdlib.h>
    #endif
    #include <sdl/SDL.h>
     
    /*#ifdef WIN32
      #pragma comment(lib, "SDL.lib")
      #pragma comment(lib, "SDLmain.lib")
    #endif
    */
    int main ( int argc, char** argv )
    {
        // initialize SDL video
        if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
        {
            printf( "Unable to init SDL: %s\n", SDL_GetError() );
            return 1;
        }
     
        // make sure SDL cleans up before exit
        atexit(SDL_Quit);
     
        // create a new window
        SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16,
                                               SDL_HWSURFACE|SDL_DOUBLEBUF);
        if ( !screen )
        {
            printf("Unable to set 640x480 video: %s\n", SDL_GetError());
            return 1;
        }
     
        // load an image
        SDL_Surface* bmp = SDL_LoadBMP("cb.bmp");
        if (!bmp)
        {
            printf("Unable to load bitmap: %s\n", SDL_GetError());
            return 1;
        }
     
        // center the bitmap on screen
        SDL_Rect dstrect;
        dstrect.x = (screen->w - bmp->w) / 2;
        dstrect.y = (screen->h - bmp->h) / 2;
     
        // program main loop
        bool done = false;
        while (!done)
        {
            // message processing loop
            SDL_Event event;
            while (SDL_PollEvent(&event))
            {
                // check for messages
                switch (event.type)
                {
                    // exit if the window is closed
                case SDL_QUIT:
                    done = true;
                    break;
     
                    // check for keypresses
                case SDL_KEYDOWN:
                    {
                        // exit if ESCAPE is pressed
                        if (event.key.keysym.sym == SDLK_ESCAPE)
                            done = true;
                        break;
                    }
                } // end switch
            } // end of message processing
     
            // DRAWING STARTS HERE
     
            // clear screen
            SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
     
            // draw bitmap
            SDL_BlitSurface(bmp, 0, screen, &dstrect);
     
            // DRAWING ENDS HERE
     
            // finally, update the screen :)
            SDL_Flip(screen);
        } // end main loop
     
        // free loaded bitmap
        SDL_FreeSurface(bmp);
     
        // all is well ;)
        printf("Exited cleanly\n");
        return 0;
    }

    VI ] Build Logs :


    Project : sdlapp
    Compiler : Microsoft Visual C++ Toolkit 2003 (called directly)
    Directory : C:\projects\projHuit\
    --------------------------------------------------------------------------------
    Switching to target: default
    cl.exe /nologo /Od /Od /W3 /W4 /W3 /IC:\VCToolkit2003\include /IC:\PlatformSDK\Include /I"C:\Program Files\Microsoft.NET\SDK\v1.1\include" /IC:\dxsdk\Include /c main.cpp /Fo.objs\main.obj
    main.cpp
    cl : Command line warning D4025 : overriding '/W3' with '/W4'
    cl : Command line warning D4025 : overriding '/W4' with '/W3'
    link.exe /nologo /subsystem:windows /LIBPATH:C:\VCToolkit2003\lib /LIBPATH:"C:\Program Files\Microsoft.NET\SDK\v1.1\Lib" /LIBPATH:C:\PlatformSDK\Lib /LIBPATH:C:\dxsdk\Lib /out:sdlapp.exe SDLmain.lib SDL.lib .objs\main.obj /NODEFAULTLIB:msvcrt.lib
    SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol _exit imported in function _main
    SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol __iob imported in function _ShowError
    SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol _fclose imported in function _cleanup_output
    SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol __pctype imported in function _ParseCommandLine
    SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol ___mb_cur_max imported in function _ParseCommandLine
    SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol __isctype imported in function _ParseCommandLine
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__strrchr referenced in function _main
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__remove referenced in function _cleanup_output
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__fopen referenced in function _cleanup_output
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__fgetc referenced in function _cleanup_output
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__setbuf referenced in function _WinMain@16
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__setvbuf referenced in function _WinMain@16
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__freopen referenced in function _WinMain@16
    sdlapp.exe : fatal error LNK1120: 8 unresolved externals
    Process terminated with status 1 (0 minutes, 2 seconds)
    9 errors, 6 warnings


    VII ] Question :

    Mes paramètres semblent de linkage corrects d'ou peux provenir l'erreur, quelles sont les pistes à explorer ?

    Merci d'avance (ps : mon choix se porte uniquement sur le compilateur Microsoft... pour l'instant)



  2. #2
    Membre éprouvé

    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2005
    Messages
    634
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2005
    Messages : 634
    Points : 1 205
    Points
    1 205
    Par défaut
    Malheureusemen VC++ Toolkit 2003 pose problème car pour utiliser SDL il faut utiliser la bibliothèque Runtime en DLL multithreadée (dans les options du compilo), et cette bibliothèque n'est pas livrée avec VC++ Toolkit 2003 (lorsqu'on met l'option il manque un .lib). Donc à moins que tu trouves les bibliothèques je ne sais comment, ça ne marchera pas.
    Fiquet
    - FAQ SDL
    - FAQ C++

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 15
    Points : 14
    Points
    14
    Par défaut Quelle sont les lib manquantes ?
    Merci pour ta réponse

    De quelles librairies s'agit-il ?

    msvcrt.lib, msvcprt.lib ?

    en cherchant depuis trois jours j'ai trouvé ces infos :

    http://root.cern.ch/root/Procedure/P...Visual%20C.htm

    j'ai téléchargé la lib trouvée sur cette page (en l'occurence "msvcprt.lib") mais qui ne semble pas utilisable en l'état : un fichier "msvcprt.def" est disponible pour générer un fichier "msvcprt.lib" utilisable, mais la procédure m'échappe.

    Des infos complémentaires seraient les bienvenues, en effet je rencontre un problème similaire avec d'autres librairies (en l'occurence celle du framework kjAPI) qui semble aussi nécessiter le multithread.
    Je pense qu'il pourrait être salutaire de rédiger un tutorial clair et complet sur ce problème qui concerne tous les utilisateurs de codeblocks avec le compilateur vc++ toolkit 2003. C'est une tâche à laquelle je serais enchanté de m'atteller dès que je pourrais résoudre le problème posé par ces libs manquantes.

    Merci d'avance.


  4. #4
    Membre éprouvé

    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2005
    Messages
    634
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2005
    Messages : 634
    Points : 1 205
    Points
    1 205
    Par défaut
    Oui il y a celles-ci. Voici les bibliothèques correspondante selon options de compilation :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    Reusable Library            Switch    Library    Macro(s) Defined
    ----------------------------------------------------------------
    Single Threaded             /ML       LIBC       (none)
    Static MultiThread          /MT       LIBCMT     _MT
    Dynamic Link (DLL)          /MD       MSVCRT     _MT and _DLL
    Debug Single Threaded       /MLd      LIBCD      _DEBUG
    Debug Static MultiThread    /MTd      LIBCMTD    _DEBUG and _MT
    Debug Dynamic Link (DLL)    /MDd      MSVCRTD    _DEBUG, _MT, and _DLL
    Si tu veux creuser un peu plus regarde chez Microsoft si tu peux les avoir réellement, moi je n'avais rien trouvé, et je ne sais pas où se situe la légalité si tu trouves des versions sur le net. Autrement une solution gratuite c'est passer à VC++ 2005 Express .
    Fiquet
    - FAQ SDL
    - FAQ C++

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

Discussions similaires

  1. Problème SDL avec CodeBlock
    Par dr_nietzsche dans le forum Windows
    Réponses: 1
    Dernier message: 11/12/2008, 21h09
  2. Problème de linkage SDL avec Builder 6 pro
    Par Invité dans le forum SDL
    Réponses: 5
    Dernier message: 28/04/2006, 02h44
  3. Sdl avec devC++
    Par leonardoo dans le forum SDL
    Réponses: 2
    Dernier message: 23/01/2006, 20h58
  4. Réponses: 1
    Dernier message: 28/10/2004, 10h45
  5. [VB.NET] Problème avec un OptionButton dans Excel 2003
    Par alfprod dans le forum Windows Forms
    Réponses: 3
    Dernier message: 09/09/2004, 13h40

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