Thread: how to link to internal functions in a library

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    48

    how to link to internal functions in a library

    I am using an open source library, there are quite a few interesting functions prototypes defined this way in a non-interface header file:

    #define somefunction _somefunction
    void somefunction(int a);

    I write my routine which calls somefunction(). After include the non-interface header, my routine can compile, but failed to link to the library. So I linked to the *.o files directly. It works, but the solution is ugly.

    So the questions is how to reuse the internal functions from a library. Any suggestion?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You're not meant to use internal functions from some other library.

    If you really want to export the function from the library, then you need to remove this line
    #define somefunction _somefunction

    Which is OK, if you're never going to push any changes to that library, or make your own source code available for others.

    But if you do want to publish anything, you need another approach (or a good explanation for the library maintainers).
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. changing internal representation of a struct library
    By fisheromen1031 in forum C Programming
    Replies: 4
    Last Post: 11-13-2009, 06:24 PM
  2. Replies: 1
    Last Post: 01-11-2007, 05:22 PM
  3. Replies: 19
    Last Post: 01-12-2006, 11:04 AM
  4. Dev C++ library to link
    By WDT in forum Networking/Device Communication
    Replies: 3
    Last Post: 03-20-2004, 11:20 AM
  5. local IP identification via C internal functions
    By andrew in forum C Programming
    Replies: 0
    Last Post: 12-19-2001, 06:46 AM

Tags for this Thread