Thread: Missing library

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    21

    Missing library

    I'm learning windows game programming from a book. Anyway for one of the game examples, it wants me to change the linker setting to include: msimg32.lib

    It tells me to look in the lib folder that comes with my compiler. However I've looked in the lib folders of the two different compilers I have and that file isn't in either. Am I missing the point of what to do here. If not where can I get this file. None of the game examples will compile without it.

    Thanks

  2. #2
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    search your computer for it,
    or i can mail it to ya.
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    It comes with VC++ 6.0, Visual Studio .NET 2003, and the free with current version of Windows SDK

  4. #4
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Whenever i need a library, i just search my Visual Studio folder, it's always there.
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    21
    Ok, thanks for that. Having searched my comp for it I've just discovered that It was in lib file all along, I just didn't see it.

    Any I've now got a new problem. One of the examples uses two functions: max() and min()

    When I try to comile however I get:

    "ufo.cpp": E2268 Call to undefined function 'max' in function HandleKeys() at line 84

    The thing is the book comes with a source code disk and I have litteraly inported the project from the disk. As they seem to to be missing from the main code, and the book says nothing about them, I'm stuck what to do. Unless anyone knows where they are defined or can help me get round the problem.

    Just incase it helps, I've included how they are used:

    Code:
    void GameCycle()
    {
      // Update the saucer position
      g_iSaucerX = min(500 - g_pSaucer->GetWidth(), max(0, g_iSaucerX + g_iSpeedX));
      g_iSaucerY = min(320, max(0, g_iSaucerY + g_iSpeedY));
    
      // Force a repaint to redraw the saucer
      InvalidateRect(g_pGame->GetWindow(), NULL, FALSE);
    }
    
    void HandleKeys()
    {
      // Change the speed of the saucer in response to arrow key presses
      if (GetAsyncKeyState(VK_LEFT) < 0)
        g_iSpeedX = max(-g_iMAXSPEED, --g_iSpeedX);
      else if (GetAsyncKeyState(VK_RIGHT) < 0)
        g_iSpeedX = min(g_iMAXSPEED, ++g_iSpeedX);
      if (GetAsyncKeyState(VK_UP) < 0)
        g_iSpeedY = max(-g_iMAXSPEED, --g_iSpeedY);
      else if (GetAsyncKeyState(VK_DOWN) < 0)
        g_iSpeedY = min(g_iMAXSPEED, ++g_iSpeedY);
    }
    Thanks in advance.

  6. #6
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    that looks like it was just intended to be included in another project, it doesn't look like it should be used by itself.

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Code:
    #define max(a, b)  (((a) > (b)) ? (a) : (b))
    Its defined like the above

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    21
    Wraithan: No, thats part of the code from the source code for one of the complete games. I can't see why the book has suppliedcode that won't even compile.

    Ancient Dragon: I added that code and its done nothing, was I just supposed to add that, or am I missing something here.

    Sorry to keep asking questions but this example is really annoying me and I want it to compile.

    Thanks

  9. #9
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    you should not use a macro to evaluate max like the one I posted previously because it will evaluate the expression more than once causing "--g_iSpeedX" to be executed twice. Write a small function to avoid that problem

    Both these functions must appear before any of the other code you posted. They assume they are evaluating integers. You might have to change the integers to some other data type, such as whetver g_iSaucerX is. Since this is a c++ board I'm sure someone else can write a simple template to take care of any data type.

    Code:
    int max(int a, int b)
    {
       return (a > b) ? a : b;
    }
    
    int min(int a, int b)
    {
      return (a > b) ? b : a;
    }
    Last edited by Ancient Dragon; 11-30-2005 at 08:13 PM.

  10. #10
    Registered User
    Join Date
    Oct 2005
    Posts
    21
    Thank you all.

    After fixing that successfully, and another 3 problems after that I've finally got all working as it should be. Thanks a lot for everyone thats helped

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  3. Erros in Utility Header File
    By silk.odyssey in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2003, 06:17 AM
  4. header file bringing errors?
    By bluehead in forum Windows Programming
    Replies: 4
    Last Post: 08-19-2003, 12:51 PM
  5. errors in my class....
    By o0obruceleeo0o in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2003, 03:22 AM