Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C++ problem loading images

Options
  • 23-02-2007 5:55pm
    #1
    Closed Accounts Posts: 882 ✭✭✭


    Hi guys, having a problem loading images (sprites) for a college assignment. It works fine in college, but won't work on my laptop at home. I'm using visual C++ 2005 Express. This is the error:


    sprite.obj : error LNK2019: unresolved external symbol _IMG_Load referenced in function "public: void __thiscall Sprite::initialise(void)" (?initialise@Sprite@@QAEXXZ)
    Debug/Lab2.exe : fatal error LNK1120: 1 unresolved externals


    here's the the .cpp file:

    #include <iostream> // Needed for cin, cout, cerr, endl
    #include "SDL.h" // Needed for SDL use
    #include "SDL_ttf.h" // Needed for using fonts for text drawing
    #include "SDL_image.h" // Used for loading images
    #include "sprite.h"
    using namespace std;



    Sprite::Sprite(){}


    void Sprite::initialise()
    {
    x=300;
    y=300;

    // Load the sprite image ********************************
    sprite = IMG_Load("D:\\2E3\\2E3Labs\\Lab2\\sprite.gif"); <<<<<<<<<<< this is the problem part!!!!!!!
    ********************************
    if(!sprite)
    {
    cerr << "IMG_Load: " << TTF_GetError() << endl;
    exit(1);
    }


    }

    void Sprite::display(SDL_Surface *surf)
    {

    // Draw the sprite at the required location.
    SDL_Rect loc;
    loc.w = loc.h = 0;
    loc.x = static_cast<int>(x);
    loc.y = static_cast<int>(y);

    SDL_BlitSurface(sprite, 0, surf, &loc);
    }


    The code works fine in college, but it won't work at home, so i presume it's the setup of the project and not a code problem.

    Can anyone help? i posted it on the course forum but i've had no replies yet and i want to get it started asap!

    cheers!


    }


Comments

  • Registered Users Posts: 2,320 ✭✭✭Q_Ball


    this is gonna sound simple but i got it from here
    Yes, check that a) you have the libraries included in the build, and that b) you have set your application to Debug Multithreaded DLL (for Debug build, Multithreaded DLL for non Debug)

    and the obvious having the sprite in the directory specified. You have it stored on your D drive in college, is it on the D drive on your laptop?

    It does sound like a linker problem alright


  • Closed Accounts Posts: 882 ✭✭✭cunnins4


    oops double post


  • Closed Accounts Posts: 882 ✭✭✭cunnins4


    cheers. didn't have SDL_image.lib linked. all fixed.


    now to get my assignment done......... argghh!


    thanks again!


Advertisement