Thread: New article on creating shared libraries on Linux with GCC

  1. #1
    Administrator webmaster's Avatar
    Join Date
    Aug 2001
    Posts
    1,012

    New article on creating shared libraries on Linux with GCC

    Written by anduril462, this article covers creating and configuring shared libraries on Linux, using GCC: Shared libraries with GCC on Linux - Cprogramming.com

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Nice job. I learned what "PIC" refers to.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    5
    My highest compliments to anduril462 for an exceptionally well written article. You've covered everything that in my view is important knowing about shared library creation and usage. (Especially like the nice formatting you've used to highlight the example commands and output. Makes it all the more readable.)

    For anyone who wishes to build on knowledge gained from this article by learning about loading C++ functions and classes dynamically using the dlopen API, I found this useful: C++ dlopen mini HOWTO

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by webmaster View Post
    Written by anduril462, this article covers creating and configuring shared libraries on Linux, using GCC: Shared libraries with GCC on Linux - Cprogramming.com
    It's a nice, concise article on the mechanics of producing a shared library (which tools to use, how to invoke them, etc.)

    What is missing is a discussion of the implications of shared code -- the requirements imposed by backwards compatibility, interface stability, binary compatibility in general. Compiling position-independent and linking dynamically is really only the first step to creating a shared library. Nailing the right interface on the first try, or at least setting yourself up to be able to fix it in the future without forcing a global recompile of everything that depends on your library, is the next step.

    EDIT: Just saying It's a great contribution, it just leaves open the possibility of more in the future.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Thanks for the positive response.

    @aj17: All credit to webmaster for the nice formatting. Thanks for the dlopen reference, maybe it can be linked in my article or in a short follow up.

    @brewbuck: Yeah, that would be a good idea. Care to give it a shot?

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by anduril462 View Post
    @brewbuck: Yeah, that would be a good idea. Care to give it a shot?
    Well, I suppose now I have to. Heh.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by brewbuck View Post
    Well, I suppose now I have to. Heh.
    Just wanted to let everybody know that I'm actually working on this. Just give me a week or so
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    Registered User
    Join Date
    Mar 2011
    Posts
    5

    Thumbs up

    Quote Originally Posted by brewbuck View Post
    Just wanted to let everybody know that I'm actually working on this. Just give me a week or so
    Cool

  9. #9
    Registered User
    Join Date
    Apr 2010
    Posts
    88
    This was something I wanted to learn, thanks for the article. Just had a first read through, may have questions in the next few days as I mess with it.
    W7, Ubuntu -- mingw, gcc, g++, code::blocks, emacs, notepad++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. shared libraries
    By kris.c in forum Linux Programming
    Replies: 5
    Last Post: 12-25-2006, 08:08 PM
  2. Shared Libraries and such
    By divineleft in forum Linux Programming
    Replies: 3
    Last Post: 11-04-2006, 08:38 PM
  3. Problems with shared libraries
    By nilesh82 in forum C Programming
    Replies: 2
    Last Post: 10-02-2005, 06:29 AM
  4. shared libraries
    By Raven Arkadon in forum C++ Programming
    Replies: 5
    Last Post: 06-27-2005, 07:11 AM
  5. Linux Security Article by NSA
    By xddxogm3 in forum Tech Board
    Replies: 4
    Last Post: 01-31-2005, 09:31 AM