Thread: Mingw undefined references.

  1. #1
    60% Braindead
    Join Date
    Dec 2005

    Mingw undefined references.

    I just tried building a windows program in mingw. I built mingw & msys off of auto installing exes.

    It doesnt seem to be a library issue per-se. Rather, it seems the library is missing some definitions. I would put this in the C++ board/Windows board, but it seems more a problem with mingw.

    C:/DOCUME~1/USER1~1/LOCALS~1/Temp/ccmqbaaa.o(.text+0x57):rpg.cpp: undefined reference to `DeleteObject@4'
    C:/DOCUME~1/USER1~1/LOCALS~1/Temp/ccmqbaaa.o(.text+0xf0):rpg.cpp: undefined reference to `CreateCompatibleDC@4'
    C:/DOCUME~1/USER1~1/LOCALS~1/Temp/ccmqbaaa.o(.text+0x10a):rpg.cpp: undefined reference to `SelectObject@8'
    C:/DOCUME~1/USER1~1/LOCALS~1/Temp/ccmqbaaa.o(.text+0x12c):rpg.cpp: undefined reference to `GetObjectA@12'
    C:/DOCUME~1/USER1~1/LOCALS~1/Temp/ccmqbaaa.o(.text+0x177):rpg.cpp: undefined reference to `BitBlt@36'
    C:/DOCUME~1/USER1~1/LOCALS~1/Temp/ccmqbaaa.o(.text+0x18c):rpg.cpp: undefined reference to `SelectObject@8'
    C:/DOCUME~1/USER1~1/LOCALS~1/Temp/ccmqbaaa.o(.text+0x19a):rpg.cpp: undefined reference to `DeleteDC@4'
    It only bugs me about my paint procedures. But, not all of them seem to be bugged. Its a weird issue, it says nothing else. No missing libraries, nothing.

    Heres my bugged code for reference:
      case WM_CREATE:
       ScreenDisplay_Object = LoadBitmap(GetModuleHandle(NULL),"C:\\ball.bmp");
       if(ScreenDisplay_Object == NULL)
        MessageBox(hwnd, "Could not load object!", "Error", MB_OK | MB_ICONEXCLAMATION);
      case WM_PAINT: {
       BITMAP bm;
       PAINTSTRUCT ps;
       HDC hdc = BeginPaint(hwnd, &ps); // 31
       HDC hdcMem = CreateCompatibleDC(hdc);
       HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, ScreenDisplay_Object); //34
       GetObject(ScreenDisplay_Object, sizeof(bm), &bm);
       BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
       SelectObject(hdcMem, hbmOld);
       EndPaint(hwnd, &ps);
       return DefWindowProc(hwnd, msg, wParam, lParam);
    I looked in the mingw wiki / documentation. It didint mention this :/. Anyone have mingw do the same thing to them?
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  2. #2
    Join Date
    Jan 2002
    Looks like you haven't linked with the gdi32 library (-lgdi32) - exactly what instructions are you using to build your program?

    For example, for a single file windows program, test.cpp, you would build it as follows from a command prompt or msys command line:
    g++ test.cpp -mwindows -o test.exe
    The -mwindows switch is passed to the linker and ensures basic configuration for a windows application including the linking of some common windows libraries such as gdi32, kernel32 and user32.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    60% Braindead
    Join Date
    Dec 2005
    Oh, mingw is so different then borland, always catchs me offguard. Thank you for that ken.
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 12:45 PM
  2. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 05:42 PM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  4. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 12:02 PM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 10:51 AM
Website Security Test