Thread: Do I really need a dynamic library or can I use .o files?

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    1

    Do I really need a dynamic library or can I use .o files?

    Hi Im fairly new to C..but have many years programming java and want to do things like using the classpath option in java in anyone is familiar.

    I want to compile several source into object files and I guess link them dynamically to keep my executable small as possible so I guess I want to link to .o files without going the through process of creating a dynamic library.

    Can this be done or do I need to have a .so (on linux) to do this?

    I am in habit of breaking things in many source files even while I am learning C now...for ex when I do some tests I typically create a source

    func.c

    where I place all my functions

    it enables me to create several main programs for testing...

    I know I can compile these to object files with a gcc -c option and even include func.o when I compile my main(s) and from my understanding the .o files get added to the executable....

    what I want is to not add them to the executable but instead specify them at compile time and runtime.

    Can I do this? If so can someone please enlighten me how...the options of gcc etc..are quite a handfull...

    from the java side its like creating a class and compiling another using the classpath option if that makes sense.

    Thanks in advance.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You need .so files for the kind of dynamic linking you're talking about at the moment.

    There is also an interface for accessing object files under program control as well.
    dlopen(3) - Linux man page
    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. Static library vs Dynamic library
    By Alegomaster in forum C Programming
    Replies: 5
    Last Post: 03-17-2011, 07:26 PM
  2. shared library, but not dynamic !?
    By ccox421 in forum C Programming
    Replies: 11
    Last Post: 03-17-2009, 01:03 PM
  3. Dynamic Linking Library questions
    By Blackroot in forum C++ Programming
    Replies: 4
    Last Post: 10-11-2007, 03:04 AM
  4. Replies: 19
    Last Post: 01-12-2006, 11:04 AM
  5. What is a DLL (Dynamic Link Library)
    By Perica in forum C++ Programming
    Replies: 8
    Last Post: 11-02-2002, 01:31 PM