1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Undefined reference to "function name"

Discussion in 'Software Development' started by tkh, Sep 27, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. tkh

    tkh Thread Starter

    Joined:
    Jan 10, 2004
    Messages:
    138
    Hi guys,

    I am currently using Linux trying to compile a C program but it keeps returning an "Undefined reference to <functionName>".. generally what is the source of problem? I tried adding in the relevant libraries but to no avail.

    Thanks
     
  2. Sponsor

  3. Chicon

    Chicon

    Joined:
    Jul 29, 2004
    Messages:
    6,650
    Hi tkh,

    The probleme may occur when the library (a file with the .h extension) in which the function is defined is missing or mislocated.
    You should check the library path used for the pre-compiler.
    Otherwise, you have to check your coding, C language is case sensitive.
     
  4. AGCurry

    AGCurry

    Joined:
    Jun 15, 2005
    Messages:
    431
    This is a common confusion in C programming.

    The library is NOT the same as the header (.h) file. C libraries are collections of compiled objects which are LINKED to your object code by the linker. Header files are lexically included by the preprocessor.

    When you compile, you need to make sure that the libraries are where they're supposed to be AND the header files (INCLUDE=...) are where they're supposed to be. Either one can mess you up.
     
  5. Chicon

    Chicon

    Joined:
    Jul 29, 2004
    Messages:
    6,650
    Thanks for refreshing my memory, AGC !
     
  6. blaqDeaph

    blaqDeaph

    Joined:
    Nov 22, 2005
    Messages:
    869
    Thats just the tip of the iceberg, because header files can contain refrences to multiple libraries, by including other header files in it. A good example is the windows.h header, which actually includes other header files like winuser.h

    Trying to find out what library you need can be a mess, your best bet is to download the full Development kit that contains all the headers/libraries. Otherwise it's like finding a needle in the haystack.
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads
  1. junfan
    Replies:
    0
    Views:
    174
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/504721