Menu

Linker problems with resource files (*.rc)

2002-08-24
2012-09-26
  • Nobody/Anonymous

    I've been teaching myself c++ over the last 15 months or so. I've been using Borland C++ Builder 5.5, but I can't seem to get it to compile resource files (you can't really make windows proggies without them), so I decided to give Dev-C++ a try. 
    I am really impressed with how well it seems to work. 

    But once again, I am having problems with getting it to compile when I make resource files for it (with Dev-C++).  When I click on the error in the errors box, a message box pops up and says it's a generic linker problem in my source code (but it won't tell me what's really going on).  I am trying to learn windows programming, but without resource files you can't make things like: dialog boxes, menus (unless you reprogram them every time), icons, and many more things).  Here's some of the source code (maybe one of you guys can pick out my problem):

    Icon.rc----------------------------------------------------
    #include <resource.h>

    IDR_MYMENU MENU
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "E&xit", ID_FILE_EXIT
        END

        POPUP "&Stuff"
        BEGIN
            MENUITEM "&Go", ID_STUFF_GO
            MENUITEM "G&o somewhere else", 0, GRAYED
        END
    END
    ------------------------------------------------------------

    Resource.h-----------------------------------------------
    #define IDR_MYMENU 101
    #define ID_FILE_EXIT 9001
    #define ID_STUFF_GO 9002
    ------------------------------------------------------------

    (A small chunk of main.cpp)----------------------------
    #include <resource.h>
    ...
    wincl.lpszMenuName = (HMENU)MAKEINTRESOURCE(IDR_MYMENU);
    ------------------------------------------------------------

    I'm not even sure if this source code's gonna work even if it did compile.  The first problem with this source code is that the compiler couldn't find "resource.h", so I moved it to the include directory, and relaced the quotation marks and replaced them with < and >, respectively.  It can now find the .h file, but it's still not compiling, and further more, not telling me what the problem is.  Here are the 2 errors on compile:

    Line:           Unit:                       Message:
    G__~1.exe C:\Devc\G__~1.exe   Simple\: No such
                                                    file or directory
    G__~1.exe C:\Devc\G__~1.exe  Window.res No
                                                   such file or direct-
                                                   ory

    What the h*** is that?  those are the only errors that I get (and I can't make much sense of them).  Any of you guys have a solution?  Thanks--

     
    • Nobody/Anonymous

      The error message indicates to me that the linker cannot find the .RES file which gets created by WINDRES.EXE from the .RC file. (This is usually perfromed at the last step of compilation. Check out the makefile.win.)

      Can you check where your .RES file is. (Mine usually gets put in the same folder as the project.)

      Under PROJECT you can 'Add Resource File'. This should tell Dev-C++ where the resource file is when building the makefile.

      BlakJak :]

      P.S. There is a 'feature' of Dev-C++ that you must be aware of. If you modify only your RC file then re-compile, it will not automatically run WINDRES. There is a workaround to this posted somewhere on this forum. The alternative is to re-build all.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.