Thread: Makefiles with shared libs

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    913

    Makefiles with shared libs

    I have a makefile that looks like this:

    Code:
    str_remove.o : str_remove.c
    	gcc -c str_remove.c
    	gcc -fPIC -shared -o libstr_remove.so str_remove.o
    str_insert.o : str_insert.c
    	gcc -c str_insert.c
    	gcc -fPIC -shared -o libstr_insert.so str_insert.o
    str_move.o : str_move.c str_remove.c str_insert.c
    	gcc -c str_move.c str_remove.c str_insert.c
    	gcc -fPIC -shared -o libstr_move.so str_move.o
    remove and insert are fine, move has a problem. It doesnt use the shared libs just created and it rebuilds everything.

    How should i do it?

    Thanks

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    Yes, I think you have your dependancies mixed up. You have to answer what str_move.o depends on. It would seem to me to depend on libstr_remove.so libstr_insert.so yet these are not explicitly targets in the makefile. Perhaps you want

    str_remove.o : str_remove.c
    gcc -c str_remove.c

    libstr_remove.so: str_remove.o
    gcc -fPIC -shared -o libstr_remove.so str_remove.o

    str_insert.o : str_insert.c
    gcc -c str_insert.c

    libstr_insert.so:
    gcc -fPIC -shared -o libstr_insert.so str_insert.o

    str_move.o : libstr_remove.so libstr_insert.so
    gcc -c str_move.c
    gcc -fPIC -shared -o libstr_move.so str_move.o

    If this doesn't work try http://www.advancedlinuxprogramming.com/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex and Shared Memory Segment Questions.
    By MadDog in forum Linux Programming
    Replies: 14
    Last Post: 06-20-2010, 04:04 AM
  2. Replies: 7
    Last Post: 02-06-2009, 12:27 PM
  3. How do I make shared libs on Linux?
    By cpjust in forum C Programming
    Replies: 13
    Last Post: 11-05-2007, 04:54 PM
  4. Writing input from a file into shared memory
    By RazielX in forum C Programming
    Replies: 2
    Last Post: 09-23-2004, 12:34 PM
  5. Managing shared memory lookups
    By clancyPC in forum Linux Programming
    Replies: 0
    Last Post: 10-08-2003, 04:44 AM