Problem with Dev-C++ 4

This is a discussion on Problem with Dev-C++ 4 within the Windows Programming forums, part of the Platform Specific Boards category; When I compile the project with Dev-C++ 4.9.9.2, then it works fine, but if I try to compile it with ...

  1. #1
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318

    Problem with Dev-C++ 4

    When I compile the project with Dev-C++ 4.9.9.2, then it works fine, but if I try to compile it with Dev-C++ 4, I get linker errors: "c:\programs\forexample\examples\winmenu\main.o(.t ext+0x497):main.cpp: undefined reference to `GetDeviceCaps@8'
    c:\programs\forexample\examples\winmenu\main.o(.te xt+0x4c8):main.cpp: undefined reference to `GetDeviceCaps@8'
    c:\programs\forexample\examples\winmenu\main.o(.te xt+0x525):main.cpp: undefined reference to `CreateFontA@56'
    c:\programs\forexample\examples\winmenu\main.o(.te xt+0x572):main.cpp: undefined reference to `CreateFontA@56'
    "
    Code of the main file:
    Code:
    #include <windows.h>
    #include "main.h"
    #include <string>
    #include <fstream>
    #include <direct.h>
    std::string songid,destination,basename,boogi,name,var,var2,str;
    std::ifstream fin;
    std::ofstream fer;
    bool success;
    char shelp2[256];
    int gar,leng;
    using namespace std;
    bool DownloadFile(LPCTSTR URL , LPCTSTR LocalFilename); 
    typedef long (WINAPI * MYPROC)(long,LPCTSTR,LPCTSTR,DWORD,long);
    bool DownloadFile(LPCTSTR URL , LPCTSTR LocalFilename) 
    {        
        long lngRetVal;              
    	HMODULE hinstLib; 
        MYPROC ProcAdd;                                 
        BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
    	hinstLib = LoadLibrary("urlmon.dll");
      if(hinstLib != NULL)
      { 
    	ProcAdd = (MYPROC) GetProcAddress(hinstLib, "URLDownloadToFileA");
    	   if (NULL != ProcAdd) 
    	   {
                fRunTimeLinkSuccess = TRUE;
    		    lngRetVal = ProcAdd(0, URL, LocalFilename, 0, 0);
    		    fFreeResult = FreeLibrary(hinstLib);
    
    		}	
      }
    }
    HWND hww,hww2,hww3,hww4,hww5;
    char non[256],non2[500],non3[500],shelp[500];
    HMENU menu;
    HINSTANCE hThisInstance;
    HFONT hf,hf2;
    long lf,lf2;
    HDC hdc;
    LRESULT CALLBACK MainMessageHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
    	{
    		case WM_CREATE:
    		{
                 fin.open("test.txt");
                 gar=0;
                 while(fin>>boogi){
        if(gar==0){
        name+=boogi;
        gar=1;
        }
        else{
        name+=" ";
        name+=boogi;
        }
        }
        *(std::copy(name.begin(), name.end() - name.begin() < 200 ? name.end() : name.begin() + 199, shelp)) = 0;
    
                hww=CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_CHILD | WS_VISIBLE | ES_NUMBER,
    			               1, 1, 53, 23,
    			               hwnd,(HMENU) 0xED, GetModuleHandle(NULL), NULL);
      hdc = GetDC(NULL);
        lf = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
        lf2 = -MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72);
        ReleaseDC(NULL, hdc);
    hf = CreateFont(lf, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, "Times New Roman");
    SendMessage(hww,WM_SETFONT,(WPARAM)hf,TRUE);
    hf2 = CreateFont(lf2, 0, 0, 0, 500, FALSE, 0, 0, 0, 0, 0, 0, 0, "Verdana");
                hww2=CreateWindowEx(NULL,"Button","Tõmba",
                                   WS_BORDER | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                   56, 1,
                                   80, 23,
                                   hwnd,(HMENU)IDB_BUTTON,
                                   GetModuleHandle(NULL),
                                   NULL);
    SendMessage(hww2,WM_SETFONT,(WPARAM)hf2,TRUE);
    hww3=CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_CHILD | WS_VISIBLE | ES_MULTILINE,
    			               1, 26, 238, 23,
    			               hwnd,(HMENU) 0xED, GetModuleHandle(NULL), NULL);
    hww4=CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(shelp), WS_CHILD | WS_VISIBLE | ES_MULTILINE,
    			               1, 52, 238, 46,
    			               hwnd,(HMENU) 0xED, GetModuleHandle(NULL), NULL);
    SendMessage(hww3,WM_SETFONT,(WPARAM)hf,TRUE);
    SendMessage(hww4,WM_SETFONT,(WPARAM)hf,TRUE);
                hww5=CreateWindowEx(NULL,"Button","Surfa unos",
                                   WS_BORDER | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                   139, 1,
                                   90, 23,
                                   hwnd,(HMENU)IDB_BUTTON2,
                                   GetModuleHandle(NULL),
                                   NULL);
    SendMessage(hww5,WM_SETFONT,(WPARAM)hf2,TRUE);
    			/* Fall through */
    		}
            case WM_COMMAND:
            switch( wParam )
               {
            case IDM_LEAVE:
                 DestroyWindow(hwnd);
                 return 0;
            case IDM_DESTINATION:
                 MessageBox(hwnd,"Programm on täielikult illegaalne!","Programmist...",MB_OK | MB_ICONINFORMATION);
                 return 0;
            case IDB_BUTTON2:
                 system("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" http://www.u-pop.ee/uplayer");
                 return 0;
                 }
            if (LOWORD(wParam) == IDB_BUTTON)
                    {
            GetWindowText(hww,non,255);
            GetWindowText(hww3,non2,500);
            GetWindowText(hww4,non3,500);
            basename=non2;
            destination=non3;
            songid=non;
        if(_chdir(non3)==0){
        if(destination.substr(destination.length()-1,destination.length())=="\\"){
        }
        else{
        destination+="\\";
        }
    var="http://data.uno.ee/juke/songid-"+songid+"-555/songs.asx";
      var2="C:\\temp.abc";
      *(std::copy(var.begin(), var.end() - var.begin() < 200 ? var.end() : var.begin() + 199, shelp)) = 0;
      LPCTSTR URL = shelp;
      *(std::copy(var2.begin(), var2.end() - var2.begin() < 200 ? var2.end() : var2.begin() + 199, shelp2)) = 0;
      LPCTSTR File = shelp2;
      DownloadFile(URL,File);
      ifstream fi("C:\\temp.abc");
      fi>>str;
      fi>>str;
      fi>>str;
      fi>>str;
      fi.close();
      remove("C:\\temp.abc");
      leng=str.length();
      leng=leng-17;
      str=str.substr(6,leng);
      var=str;
      var2=destination+basename+".wma";
      *(std::copy(var.begin(), var.end() - var.begin() < 200 ? var.end() : var.begin() + 199, shelp)) = 0;
      URL = shelp;
      *(std::copy(var2.begin(), var2.end() - var2.begin() < 200 ? var2.end() : var2.begin() + 199, shelp2)) = 0;
      File = shelp2;
    success = DownloadFile(URL ,File); 
    	if (success == false)
    	{
      MessageBox(hwnd,"Selle numbriga laulu kas ei ole või ei saanud hetkel tõmmata!","Valmis",MB_OK | MB_ICONINFORMATION);
    	}
    	else
    	{
      MessageBox(hwnd,"Laulu tõmbamine on valmis!","Valmis",MB_OK | MB_ICONINFORMATION);
    	}
        }
        else{
    MessageBox(hwnd,"Sisestatud kausta aadress ei ole õige!","Viga!",MB_OK | MB_ICONINFORMATION);
        }
            }
    		break;
    		case WM_SIZE:
    		{
    			RECT rc;
    			GetClientRect(hwnd, &rc);
    			return 0;
    		}
    
    		case WM_DESTROY:
    		{
                fin.close();
                fer.open("test.txt");
                GetWindowText(hww4,non,500);
                fer<<non;
                fer.close();
    			PostQuitMessage(0);
    			return 0;
    		}
    	}
    
    	return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    
    HWND CreateMainWindow(INT nShow)
    {
    	WNDCLASSEX wc   = { 0 };
    	HWND       hwnd = NULL;
    
    	wc.cbSize        = sizeof(wc);
    	wc.style         = 0;
    	wc.cbClsExtra    = 0;
    	wc.cbWndExtra    = 0;
    	wc.hInstance     = GetModuleHandle(NULL);
    	wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    	wc.hIconSm       = NULL;
    	wc.lpfnWndProc   = MainMessageHandler;
    	wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    	wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);
    	wc.lpszMenuName  = NULL;
    	wc.lpszClassName = TEXT("SimpleEditContainer");
    	if(RegisterClassEx(&wc))
    	{
    		hwnd = CreateWindowEx(0, TEXT("SimpleEditContainer"), TEXT("SongDownloader 2.0"), WS_OVERLAPPEDWINDOW,
    		                      CW_USEDEFAULT, CW_USEDEFAULT, 250, 150,
    		                      NULL, NULL, GetModuleHandle(NULL), NULL);
    
    		ShowWindow(hwnd, nShow);
    	}
    	menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
        SetMenu(hwnd, menu);
    	return hwnd;
    }
    
    
    INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE reserved, LPSTR szCommand, INT nShow)
    {
    	MSG msg;
    
    	CreateMainWindow(nShow);
    
    	while ( GetMessage(&msg, NULL, 0, 0) )
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    	return (int) msg.wParam;
    }
    Last edited by maxorator; 09-26-2005 at 11:31 AM.

  2. #2
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Maybe the problem can be that Dev-C++ 4 didn't make the main.o file and said its missing and then I copied the main.o file made by Dev-C++ 4.9.9.2 to that folder.

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Make sure you are linking gdi32.lib (or probably libgdi32.a)
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Ok, I managed to add the libgdi32.a library and now I get following errors with dev-c++ 4.9.9.2:
    Code:
    c:\programs\forexample\examples\winmenu\main.o(.text+0xbec):main.cpp: undefined reference to `fstreambase::close(void)'
    c:\programs\forexample\examples\winmenu\main.o(.text+0xfb9):main.cpp: undefined reference to `fstreambase::close(void)'
    c:\programs\forexample\examples\winmenu\main.o(.text+0x1002):main.cpp: undefined reference to `ostream::operator<<(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text+0x1012):main.cpp: undefined reference to `fstreambase::close(void)'
    c:\programs\forexample\examples\winmenu\main.o(.text$_S_oom_malloc__t23__malloc_alloc_template1i0Ui+0x1a):main.cpp: undefined reference to `endl(ostream &)'
    c:\programs\forexample\examples\winmenu\main.o(.text$_S_oom_malloc__t23__malloc_alloc_template1i0Ui+0x27):main.cpp: undefined reference to `cerr'
    c:\programs\forexample\examples\winmenu\main.o(.text$_S_oom_malloc__t23__malloc_alloc_template1i0Ui+0x2c):main.cpp: undefined reference to `ostream::operator<<(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text$replace__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0UiUiUic+0x34):main.cpp: undefined reference to `__out_of_range(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text$replace__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0UiUiUic+0x8e):main.cpp: undefined reference to `__length_error(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text$resize__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0Uic+0x2c):main.cpp: undefined reference to `__length_error(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text$__rs__H3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0_R7istreamRt12basic_string3ZX01ZX11ZX21_R7istream+0xad):main.cpp: undefined reference to `streambuf::sungetc(void)'
    c:\programs\forexample\examples\winmenu\main.o(.text$replace__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0UiUiPCcUi+0x31):main.cpp: undefined reference to `__out_of_range(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text$replace__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0UiUiPCcUi+0x8e):main.cpp: undefined reference to `__length_error(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text$replace__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0UiUiRCt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0UiUi+0x72):main.cpp: undefined reference to `__out_of_range(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text$compare__Ct12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0PCcUiUi+0x2c):main.cpp: undefined reference to `__out_of_range(char const *)'
    c:\programs\forexample\examples\winmenu\main.o(.text$sbumpc__9streambuf+0xf):main.cpp: undefined reference to `_IO_getc'
    c:\programs\forexample\examples\winmenu\main.o(.text$ipfx0__7istream+0x46):main.cpp: undefined reference to `ostream::flush(void)'
    c:\programs\forexample\examples\winmenu\main.o(.text$ipfx0__7istream+0x6b):main.cpp: undefined reference to `istream::_skip_ws(void)'
    c:\programs\forexample\examples\winmenu\main.o(.text$_$_11fstreambase+0x60):main.cpp: undefined reference to `filebuf::~filebuf(void)'
    c:\programs\forexample\examples\winmenu\main.o(.text$__8ifstreami+0x9f):main.cpp: undefined reference to `fstreambase::fstreambase(int)'
    c:\programs\forexample\examples\winmenu\main.o(.text$__8ifstreamiPCcii+0xab):main.cpp: undefined reference to `fstreambase::fstreambase(int, char const *, int, int)'
    c:\programs\forexample\examples\winmenu\main.o(.text$open__8ifstreamPCcii+0x1a):main.cpp: undefined reference to `fstreambase::open(char const *, int, int)'
    c:\programs\forexample\examples\winmenu\main.o(.text$__8ofstreami+0x9f):main.cpp: undefined reference to `fstreambase::fstreambase(int)'
    c:\programs\forexample\examples\winmenu\main.o(.text$open__8ofstreamPCcii+0x1a):main.cpp: undefined reference to `fstreambase::open(char const *, int, int)'

  5. #5
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    Quote Originally Posted by JaWiB
    Make sure you are linking gdi32.lib (or probably libgdi32.a)
    to link that go to linker settings and in the box type -lgdi32

    btw? why wud u use an older version of dev?
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Because programs compiled with 4.9.9.2 are much bigger than with 4.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  2. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  3. Problem running prog I wrote in Dev C++
    By KidMan in forum C Programming
    Replies: 8
    Last Post: 09-22-2005, 01:50 AM
  4. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21