Visual C++ 8.0 (2005) with the Allegro game library: Missing MSVCR80.dll?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PieCook
    New Member
    • Jul 2007
    • 9

    Visual C++ 8.0 (2005) with the Allegro game library: Missing MSVCR80.dll?

    Error message: "The application has failed to start because MSVCR80.dll was not found. Re-installing the application may fix this problem."


    Basically, I recently purchased a game programming book, and was trying to follow along. The book uses the Allegro game library, and I was trying to configure a Visual C++ 8.0 project to compile and link to the library.

    First, I installed Allegro 4.2 by copying the lib and include folders to the Visual C++ installation folder, as well as the dll files in the bin folder to the System32 folder. I then created a test project, wrote a simple program to make sure the compiler is configured properly, and followed the instructions afterwards (Projects -> Properties -> Configuration Properties -> Linker -> Input -> Dependencies; type alleg.lib). But when I tried to run it, I got the message titled "Test 1.exe - Unable To Locate Component," which says, "The application has failed to start because MSVCR80.dll was not found. Re-installing the application may fix this problem." I tried to uninstall and re-install Visual C++, but kept getting the same error message.




    Then, I was lucky enough to have found a link where you can download DLL files (dll-files.com). So, I downloaded the file msvcr80.dll and copied it in the same folder as the main cpp file, and got a runtime error this time:

    "Runtime Error!

    Program: c:\programming tests\test1\deb ug\Test 1.exe

    R6034
    An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information.
    "





    Finally, I downloaded what I think is the runtime dll installer (they call it Microsoft Visual C++ 2005 Redistributable Package (x86)) from this link. (Can someone tell me if it's the correct link?) Because I deleted the dll file that I have manually copied, ran the runtime dll installer, but ended up with the original error message ("The application has failed to start because MSVCR80.dll was not found. Re-installing the application may fix this problem").



    I tried to Google this problem, but wasn't able to find a solution. So far, I'm stuck in the configuration part, and cannot use the rest of the book until that's been taken care of. So if anyone knows how to fix this, I would greatly appreciate it.
    Thank you.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    When you add a library has been added as an additional linker dependency, that is for a static library rather than a dll.

    With a dll, you have call LoadLibrary() to load the dll. Then call GetProcAddress( ) to get the address of the function inside the dll. This will be returned as a FARPROC. Next, delcare a function pointer with the correct arguments and return type and assign the FARPROC to it. Finally, call the function using the pointer. FreeLibrary() will unload it.

    If other functions need this library, you need to call LoadLibrary() and pass the returned HMODULE to the other functions.

    Comment

    • PieCook
      New Member
      • Jul 2007
      • 9

      #3
      Thank you for your help, but I'm afraid none of these function calls worked. I probably typed them in the wrong place. However, I got it to work otherwise.

      Here is my test program:

      Code:
      #include<allegro.h>
      int main(void)
      {
      	allegro_init();
      	set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
      	install_keyboard();
      	textout_ex(screen, font, "Hello World!", 1, 1, 10, -1);
      	textout_ex(screen, font, "Press ESCape to quit...", 1, 12, 11, -1);
      	while (!key[KEY_ESC]);
      	allegro_exit();
      	return 0;
      }
      
      END_OF_MAIN()
      When I added the LoadLibrary function, I got the following syntax error: "'LoadLibra ry' undefined; assuming extern returning int." The same thing happened with all the other functions. I don't know where I'm supposed to insert those statements.



      The way I got the program to compile was the following: After giving up on Visual Studio 8.0, I compiled the test program using Visual Studio 6.0 and it gave me no problems at all. Then, I went to the project folder and opened the file TestAllegro.dsw , a file of type VC++ 6 Workplace, and got the message, "The project 'TestAllegro.ds p' must be converted to the current Visual C++ project format. After it has been converted, you will not be able to edit this project in previous versions of Visual Studio. Convert and open this project?"

      When I clicked "Yes," it opened the project in a VC++ 8.0 solution, and I was able to get it to work with that compiler.

      By the way, I also downloaded and installed the files vcredist_x86.ex e (Visual C++ runtime) and dotnetfx.exe (fix to the .NET 2.0 Framework) from the Microsoft website, and then installed the DirectX SDK from the CD-ROM. According to the book, the SDK was only needed for a static build, but I installed it anyway.


      I hope Microsoft makes this easier in Visual Studio 2008.
      Thanks again for your help.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Originally posted by PieCook
        When I added the LoadLibrary function, I got the following syntax error: "'LoadLibra ry' undefined; assuming extern returning int." The same thing happened with all the other functions. I don't know where I'm supposed to insert those statements.
        LoadLibrary is declared in windows.h, which you didn't include. The code is in kernel32.lib which is a library added by default in both VC6.0 and VC 8.0.

        Assume these functions are in ADLL.dll:
        [code=cpp]

        void __stdcall DisplayFromDll( )
        {
        cout << "This function was called from ADLL.dll" << endl;
        }

        int __stdcall AreaOfSquare (int len, int wid)
        {
        return len * wid;
        [/code]

        The code should look like:

        [code=cpp]
        //First, load the dll into memory
        HMODULE theDll = LoadLibrary("C: \\Scratch\\Clas sDemos\\ADll\\D ebug\\ADll.dll" );
        if (!theDll)
        {
        cout << "The dll failed to load" << endl;
        return 1;
        }

        //Second, get the address of the desired function from the dll
        FARPROC addr = GetProcAddress( theDll, "DisplayFromDll ");
        if (!addr)
        {

        //Look up the error in the system errors list
        unsigned int what = GetLastError();
        if (what == ERROR_PROC_NOT_ FOUND)
        {
        cout << "Function not found in the dll" << endl;
        }
        else
        {
        cout << "Error: " << what << endl;
        }
        return 2;
        }
        cout << "The function has been located in the dll" << endl;
        //Declare a function pointer that can accept the address of the function.
        //You will need to know the function prototype to do this.
        //Dll function prototypes should be provided by the vendor of the dll
        void (__stdcall *DisplayFromDll )();
        //Type-cast the address returned from GetProcAddress to the function pointer type
        DisplayFromDll = reinterpret_cas t<void (__stdcall *)()> (addr);
        //Now use the function pointer to call the function:
        DisplayFromDll( );

        //If you don't use a .def file in the dll, you must use the mangled name
        //Second, get the address of the desried function from the dll
        addr = GetProcAddress( theDll, "AreaOfSquare") ;
        if (!addr)
        {

        //Look up the error in the system errors list
        unsigned int what = GetLastError();
        if (what == ERROR_PROC_NOT_ FOUND)
        {
        cout << "Function not found in the dll" << endl;
        }
        else
        {
        cout << "Error: " << what << endl;
        }
        return 2;
        }

        cout << "The function has been located in the dll" << endl;
        //Declare a function pointer that can accept the address of the function.
        //You will need to know the function prototype to do this.
        //Dll function prototypes should be provided by the vendor of the dll
        int (__stdcall *AreaOfSquare)( int, int);
        //Type-cast the address returned from GetProcAddress to the function pointer type
        AreaOfSquare = reinterpret_cas t<int (__stdcall*)(in t,int)> (addr);
        //Now use the function pointer to call the function:
        cout << "The area of a 6x8 square is " << AreaOfSquare(6, 8) << endl;;

        //Finally, unload the dll from memory
        FreeLibrary(the Dll);

        return 0;
        }
        [/code]

        Comment

        Working...