Thread: How do I make shared libs on Linux?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    What exactly is your link command?

    EDIT: I see the problem, anyway. You can't just list the full path to the .so file -- as you found out, that causes the path to be hard-coded. Instead, use "-L/home/test/slib -lname"
    Last edited by brewbuck; 11-05-2007 at 02:48 PM.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by brewbuck View Post
    What exactly is your link command?

    EDIT: I see the problem, anyway. You can't just list the full path to the .so file -- as you found out, that causes the path to be hard-coded. Instead, use "-L/home/test/slib -lname"
    Thanks, that did it.

    BTW, do you know when it's necessary to use the -shared flag?
    I'm still using it for building the .so library. Should I remove it there too?

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cpjust View Post
    Thanks, that did it.

    BTW, do you know when it's necessary to use the -shared flag?
    I'm still using it for building the .so library. Should I remove it there too?
    -shared is how .so libraries are created. So yes, it's necessary there. You don't need it elsewhere.

    Also remember that shared library code must be compiled with -fpic or -fPIC.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by brewbuck View Post
    -shared is how .so libraries are created. So yes, it's necessary there. You don't need it elsewhere.

    Also remember that shared library code must be compiled with -fpic or -fPIC.
    Great. and the -Bdynamic flag for ld? Is that useful, or does -shared already imply that?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. Port app from Windows to Linux
    By BobS0327 in forum Linux Programming
    Replies: 12
    Last Post: 02-12-2006, 02:35 AM
  3. libs under linux
    By moonlord in forum Linux Programming
    Replies: 1
    Last Post: 08-22-2005, 09:26 AM
  4. Dabbling with Linux.
    By Hunter2 in forum Tech Board
    Replies: 21
    Last Post: 04-21-2005, 04:17 PM
  5. Shared memory in Linux: B-TREE of structures
    By zahid in forum Linux Programming
    Replies: 3
    Last Post: 01-26-2002, 11:15 PM