linker error

This is a discussion on linker error within the C++ Programming forums, part of the General Programming Boards category; I have such code in windows program: Code: switch (message) { case WM_PAINT: HDC hDC; PAINTSTRUCT ps; hDC=BeginPaint(hwnd, &ps); MoveToEx(hDC, ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    62

    linker error

    I have such code in windows program:

    Code:
    switch (message)   {
    case WM_PAINT:
                 HDC hDC;
                 PAINTSTRUCT ps;
                 hDC=BeginPaint(hwnd, &ps);
                      MoveToEx(hDC, 0, 0, NULL);
                      LineTo(hDC, 50, 50);
                 EndPaint(hwnd, &ps);
    }
    The code without MoveToEx and LineTo works, but with them it gives those errors:

    C:\DOCUME~1\ANDRES~1\LOCALS~1\Temp\ccKoaaaa.o(.tex t+0x2b1) In function `Z15WindowProcedureP6HWND__jjl':

    [Linker error] undefined reference to `MoveToEx@16'
    [Linker error] undefined reference to `LineTo@12'

    C:\DOCUME~1\ANDRES~1\LOCALS~1\Temp\ccKoaaaa.o(.tex t+0x2b1) ld returned 1 exit status

    I use Dev-C++ Compiler. I have tryed other such graphic functions, but they don't work. Always the same errors. What would be wrong with it?

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Link to gdi32.lib. Or probably libgdi32.a

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    62
    How can I do this?

    One program I know used
    #pragma comment(lib,"libname")

    If you mean that line, it doesn't work. I tryed it. Errors are same.

  4. #4
    xhi
    xhi is offline
    !anExpert
    Join Date
    Mar 2005
    Location
    pa
    Posts
    155
    under project -> project options there is a parameters tab, and also a directories tab

    you can put the linking info in those.

  5. #5
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    I am posting this because you did not use code tags on this thread. In the furture please use Code Tags. They make your code MUCH easier to read and people will be much more likely to help you if you do. And they'll be happier about helping you

    For example:

    Without code tags:

    for(int i=0;i<5;i++)
    {
    cout << "No code tags are bad";
    }

    With Code Tags:
    Code:
    for(int i=0;i<5;i++)
    {
         cout << "This code is easy to read";
    }
    This is of course a basic example...more complicated code is even easier to read with code tags than without.

    I've added code tags for you this time. They can be added by putting [code] at the beginning of your code and [/code] at the end. More information on code tags may be found on the code tag post at the top of every forum. I also suggest you take a look at the board guildlines if you have not done so already.

    This is a common first post mistake, just remember to use [code] tags in the future and you'll get much more help.

    If this is your first time posting here the welcome, and if there's anything I can do or any questions I can answer about these forums, or anything else, please feel free and welcome to PM me.


    Good Luck with your program,

    Kermi3
    Lead Moderator
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  6. #6
    Registered User
    Join Date
    Aug 2006
    Posts
    62
    Thank you! I succeeded compiling that file. No errors.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 02:29 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 12:54 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM

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