Thread: Linker error

  1. #1
    Algorithm engineer
    Join Date
    Jun 2006
    Posts
    286

    Linker error

    I have included a header file in my c-file, laying in the same folder. The header file refers to a function in another c-file, also in the same folder. But when I try to call that function it is not found, it says "undefined reference to ...". How do I do to make my compiler find the function? Why shouldn't I just include the other c-file in my first c-file as well as the header file? Wouldn't it be like splitting up a large c-file into a couple of smaller files?

    I am using WinXP and DevCpp.

  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
    You add both source files to your project.
    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
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Hmm, post some code, it will be easier to find the solution with some solid code.

    On a side note, did you set the program up as a "project"? If not, you will not be able to link the files together anyway
    Double Helix STL

  4. #4
    Algorithm engineer
    Join Date
    Jun 2006
    Posts
    286
    Thanks! I'v never thought of making a project before.

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, 01:29 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10: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