Thread: Linker errors

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    46

    Unhappy Linker errors

    Hello,

    If you can help me I'll be very greatfull!

    I am programing using Windows XP and Dev-C++ version 4.9.8.0 which includes a full Mingw compiler system (GCC 3.2) and GDB 5.1.

    Today I hopefully installed the GrWin library correctly for making graphs. But when I run the demo I get the following errors

    [linker error] undefined reference to 'GWopen'
    [linker error] undefined reference to 'GWncolor'
    ...

    I have added the header file containing GWopen, GWncolor, etc. to the project and this still happens. I can understand why this may be happening. I haven't changed the path or added any other files to the project so the linker doesn't know where to find GWopen, GWncolor, etc.

    How do I fix this problem?

    Thank you!
    Peter

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    When you installed GrWin library, you need to find the following files

    grwin.h
    This you include in the source file
    This you seem to have managed, and the compiler can find it, otherwise it would have complained about file not found

    libgrwin.a
    This contains the actual compiled code corresponding to the interface specified by grwin.h.

    In the linker setup for the project, you need to specify the name of this library in the "additional libraries" section.
    IIRC, the name you would write in this section would be grwin (the lib prefix and .a suffix are assumed).

    You may also need to specify the location of this library in the "additional library directories" section, if this library is not in a standard place.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    46

    Thank you but new problems

    Salem, Thank you for your help. I found the libgrwin.a file and added it to the additional libraries. It was hidding in c:/dev-cpp/lib
    The errors I was getting are gone now.

    Now when I try to link I get linker errors saying
    undefinded reference to 'GetStockObject@4'
    undefinded reference to 'GetDeviceCaps@8'

    I searched on google and see that some people have fixed this problem by adding -mwindows to their compile command. I searched my system for the file *mwindows* and found nothing.

    One guy said this worked for him '>gcc -o test test.c -mwindows'

    But I'm not using a command line but an IDE (for the first time). Where do I add the -mwindows to fix the problem.

    What is -mwindows?

    Thank you,
    Peter

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    -mwindows is a command line flag, to tell the compiler / linker to produce a windows executable.

    OK, a bit of experimenting with dev-c++
    If you create a new project and choose windows program (not console program), then the linker will be automatically invoked with the -mwindows option.

    > But when I run the demo I get the following errors
    I'm assuming this demo begins with the windows 'winmain()' entry point, and not the console 'main()' entry point.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker errors
    By jw232 in forum C++ Programming
    Replies: 3
    Last Post: 06-12-2009, 12:56 PM
  2. Linker errors in VC++ 2005
    By C+/- in forum C++ Programming
    Replies: 0
    Last Post: 05-18-2007, 07:42 AM
  3. Sneaky little linker errors...
    By Tozar in forum C++ Programming
    Replies: 8
    Last Post: 10-25-2006, 05:40 AM
  4. why am i getting linker errors?
    By dantestwin in forum C++ Programming
    Replies: 11
    Last Post: 07-08-2004, 10:34 AM
  5. Linker errors with Visual C++
    By codegirl in forum C++ Programming
    Replies: 4
    Last Post: 09-11-2003, 09:20 AM