compiler keeps giving undefined reference errors

This is a discussion on compiler keeps giving undefined reference errors within the C Programming forums, part of the General Programming Boards category; hey guys so there is this program i am working on. it has a symbolic link so the main() i ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    41

    compiler keeps giving undefined reference errors

    hey guys so there is this program i am working on. it has a symbolic link so the main() i cant modify. each run or compile i would get undefined reference errors. could someone tell me some general things to look for in the programs and functions to fix it? i wont post the code since there is no use in and just need a general answer. thanks!

  2. #2
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    An undefined reference error is when you promise the compiler that a function/global varianle exists (e.g. by declaring it like "int foo();" or #include-ing a header file that does) but then you don't provide a definition in your source, nor do you link a library that does.

    It sounds like you're trying to compile more than one file at a time, so I'm guessing one of the source files references a function in another source file? If this is the case, just include both on your command-line (e.g. "cc file1.c file2.c"). Otherwise, please provide the exact error you're getting and the command-line you're using.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help me : compiler is giving strange errors
    By mehawk1 in forum C++ Programming
    Replies: 14
    Last Post: 07-02-2011, 01:33 AM
  2. Replies: 20
    Last Post: 04-11-2011, 11:42 AM
  3. Linker Errors undefined reference to 'rand'
    By asic_designer in forum C++ Programming
    Replies: 11
    Last Post: 02-01-2011, 03:57 PM
  4. Program giving errors
    By andy bee in forum C Programming
    Replies: 5
    Last Post: 08-11-2010, 10:38 PM
  5. Replies: 7
    Last Post: 10-09-2007, 02:37 PM

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