Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have a strange linking error "undefined reference to CPM_RtpRead". Here's the scenario - fileA.c (in folder A) #include "fileB.h" func1() { B1(); B2(); CPM_RtpRead(); ...... } where B1(), ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2005
    Posts
    1

    linking error: undefined reference


    Hi,

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

    Here's the scenario -

    fileA.c (in folder A)

    #include "fileB.h"

    func1()
    {
    B1();
    B2();
    CPM_RtpRead();
    ......
    }


    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?

    Thanks.

  2. #2
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    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 libcpm.so --
    Code:
    gcc -Wall myfile.c -o myfile -lcpm
    The lcpm thing means, "link against /usr/lib/libcpm.so" 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
  •