[Linker error]Undefined reference for function

This is a discussion on [Linker error]Undefined reference for function within the C Programming forums, part of the General Programming Boards category; I'm trying to combine three sources files together to run a program. I included my .h files correctly but I ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    4

    [Linker error]Undefined reference for function

    I'm trying to combine three sources files together to run a program. I included my .h files correctly but I still have this error [Linker error]Undefined reference for function. I've read that Im supposed to provide a linker with the correct path to the library but Im dont understand what this means.

    Btw I use Dev-C++ and also Cygwin and both give me the same error.

    Thanks for the help!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    How are you compiling 3 files?

    Like this?
    gcc -o myprog file1.c file2.c file3.c
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    no i do the whole makefile thing but one of the source files is not compiling b/e of this error

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    What is the library called?
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  5. #5
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,651
    Check line 14 of your Makefile. Looks like you're missing something there.

    </sarcasm>

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    Mmm - how about "post the makefile" ?
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Nov 2011
    Location
    Douala, Cameroon
    Posts
    187
    post the suspected source file and the makefile or check to see if there are some variables which you may have used as global but declared them as static. or with functions still

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker Error - Undefined Reference
    By DaNxTh3xMaNx in forum C Programming
    Replies: 3
    Last Post: 09-07-2011, 05:49 PM
  2. Linker Error/Undefined Reference
    By liljp617 in forum C Programming
    Replies: 2
    Last Post: 09-24-2008, 09:02 PM
  3. linker error undefined reference to
    By BJtoVisualcC++ in forum C++ Programming
    Replies: 3
    Last Post: 06-18-2007, 11:40 AM
  4. Linker Error (undefined reference)
    By Dae in forum C++ Programming
    Replies: 5
    Last Post: 07-15-2005, 03:50 PM
  5. Dev C++ linker error: undefined reference
    By josh_d in forum Windows Programming
    Replies: 11
    Last Post: 03-11-2004, 10:58 AM

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