Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    linking error: undefined reference


    I have a strange linking error "undefined reference to CPM_RtpRead".

    Here's the scenario -

    fileA.c (in folder A)

    #include "fileB.h"


    where B1(), B2() and CPM_RtpRead() are all defined in fileB.cpp and declared in fileB.h, both in folder B.

    Problem - While B1(), B2() are linked, I get an undefined reference for the 3rd function!! I am using binutils-2.13 and gcc-2.95. If I comment out the 3rd function, there are no unresolved references.

    Anyone got any clue of what's wrong in this picture?


  2. #2
    This is a linker error. That means the compiler was okay with your code, changing your code (assuming you need the function call) is not going to fix it.

    You need to find which shared library this function, CPM_RtpRead, lives in.
    Then add it (the library name) to your compile:

    Assume it's in --
    gcc -Wall myfile.c -o myfile -lcpm
    The lcpm thing means, "link against /usr/lib/" also.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts