Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to use .so libraries?

How to use .so libraries?
Thread Tools
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Sep 26, 2002, 07:37 PM
 
Hi,

Before I asked about .so libraries and if they were platform dependent or not.

Well, now, I am getting a Mac OS X version of the library, and I'm wondering how to use these binary libraries? Say I was using C or C++, how do I include or call them and then call functions from it?

Thanks!

Karl
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Sep 26, 2002, 11:31 PM
 
#include
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Sep 27, 2002, 08:57 AM
 
Originally posted by Kristoff:
#include
So I just do "#include <examplelibrary.so>"

when i use gcc to compile it, or whatever compiler, will it build in the library, so I don't have to distribute it with my program, or not?

Thanks!
     
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Sep 27, 2002, 03:26 PM
 
You'll need to distribute it w/ your
compiled code.

During the final link of code, you'll need
to add -Lsomedirectory -lname

ie. libfoobar.so is located in /usr/local/lib

.... -L/usr/local/lib -lfoobar

remember that the resulting binary
will remember where the library was
during the link and expects it
to be in the same place when the
binary is executed (although that
is overridable).
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Sep 27, 2002, 03:37 PM
 
Originally posted by howardm4:
You'll need to distribute it w/ your
compiled code.

During the final link of code, you'll need
to add -Lsomedirectory -lname

ie. libfoobar.so is located in /usr/local/lib

.... -L/usr/local/lib -lfoobar

remember that the resulting binary
will remember where the library was
during the link and expects it
to be in the same place when the
binary is executed (although that
is overridable).
So with this, do I still need #include <libfoobar.so>?

Thanks

karl
     
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Sep 27, 2002, 03:42 PM
 
if the library comes w/ a .h header
file that defines data structures used,
then you'd need

#include <header.h> in the .cxx file
but otherwise, all you need to do is
tell the linker to pull in the .so
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Sep 27, 2002, 04:44 PM
 
Was the .so compiled on OS X? I doubt it since OS X's shared library file extension is .dylib.

If you're compiling an OS X version, consider bundling it up as a framework.
     
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Sep 27, 2002, 04:56 PM
 
I've seen OSX dylibs named .so

It just depends on the Make rules I suppose.

Angus, I'm really not up on the differences between dylibs and frameworks.
Can you elaborate?
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Sep 27, 2002, 05:12 PM
 
On OS X, .so indicates a bundle (a blob of code that will be loaded at runtime) rather than a shared library (I don't think that Linux differentiates between the two). I'm not sure if the linker will see a library if it's called .so...

A framework is basically a nicely packaged up dylib with headers and resources inside a bundle.

If you're going to embed a library in an app, you could always compile it statically and just link it in like that.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:50 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2