title: C++ Dynamic Shared Library on Linux
body: <p>This is a follow-up to <a href="https://stackoverflow.com/q/483797/1288">Dynamic Shared Library compilation with g++</a>.</p>
  
  <p>I'm trying to create a shared class library in C++ on Linux.  I'm able to get the library to compile, and I can call some of the (non-class) functions using the tutorials that I found <a href="https://stackoverflow.com/questions/496664/c-dynamic-shared-library-on-linux/497067#497067">here</a> and <a href="https://rads.stackoverflow.com/amzn/click/com/0470147628" rel="noreferrer" rel="nofollow noreferrer">here</a>.  My problems start when I try to use the classes that are defined in the library.  The second tutorial that I linked to shows how to load the symbols for creating objects of the classes defined in the library, but stops short of <em>using</em> those objects to get any work done.</p>
  
  <p>Does anyone know of a more complete tutorial for creating shared C++ class libraries that also shows how to <em>use</em> those classes in a separate executable?  A very simple tutorial that shows object creation, use (simple getters and setters would be fine), and deletion would be fantastic.  A link or a reference to some open source code that illustrates the use of a shared class library would be equally good.</p>
  
  <hr>
  
  <p>Although the answers from <a href="https://stackoverflow.com/q/483797/1288">codelogic</a> and <a href="https://stackoverflow.com/questions/496664/c-dynamic-shared-library-on-linux/497067#497067">nimrodm</a> do work, I just wanted to add that I picked up a copy of <a href="https://rads.stackoverflow.com/amzn/click/com/0470147628" rel="noreferrer" rel="nofollow noreferrer">Beginning Linux Programming</a> since asking this question, and its first chapter has example C code and good explanations for creating and using both static and shared libraries.  These examples are available through Google Book Search in <a href="http://books.google.com/books?hl=en&amp;id=7q0TFMi7FIkC&amp;dq=beginning+linux+programming&amp;printsec=frontcover&amp;source=web&amp;ots=ko8ox73Gd6&amp;sig=Fbp6iqNbeRaADHOUB0Px-99uaY8&amp;sa=X&amp;oi=book_result&amp;resnum=3&amp;ct=result#PPA10,M1" rel="noreferrer">an older edition of that book</a>.</p>