 |
 |
How to use .so libraries?
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
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
|
|
|
|
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
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
|
|
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).
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|