Re: Base class and OOP in C

From: Paul Pluzhnikov (ppluzhnikov-nsp_at_charter.net)
Date: 03/29/05

  • Next message: Russell Shaw: "Hash tables"
    Date: Tue, 29 Mar 2005 07:34:23 -0800
    
    

    Måns Rullgård <mru@inprovide.com> writes:

    > If you change your declarations slightly, it will work:

    This is the answer to the question OP didn't ask ("Why doesn't my
    scheme work?"), but not to the question he did ask:

    >> I want the derived modules to link with the base library, so that my
    >> application can link with only the derived modules and still be able
    >> to call the base functions without having to link to that library or
    >> call 'wrapper' functions in the derived modules.
    >>
    >> Is there a way to do this?

    Yes if both base and derived are built as shared libraries;
    otherwise no.

    For the shared library case, simply link derived against base:

      gcc -shared -o libbase.so base*.o
      gcc -shared -o libderived.so derived*.o -L. -lbase

      gcc main.c -L. -lderived # -lbase is "automagically" linked

    Cheers,

    -- 
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.
    

  • Next message: Russell Shaw: "Hash tables"