Re: Dynamic Linking
Re: Dynamic Linking
- Subject: Re: Dynamic Linking
- From: Jason Moore <email@hidden>
- Date: Wed, 27 Mar 2002 10:21:37 -0600
Thanks for the help! Just a few extra questions..
Where in ProjectBuilder do i add the libcrypto.dylib file?
What #include should i use (<crypto/crypto.h>?)?
After examining the contents of /usr/lib/ i found the following four
libraries:
libcrypto.0.9.dylib
libcrypto.dylib
libssl.0.9.dylib
libssl.dylib
which should i use to get all the crypto functions of OpenSSL
(differences?)?
Thanks again for all the help..
Jason
On Wednesday, March 27, 2002, at 02:01 AM, Sherm Pendley wrote:
I don't want to statically link the library to my app.
You're in luck, then; what you want will happen automatically.
Libcrypto and libssl are both supplied as dynamic libraries, not
static. You'd have to take special steps if you *did* want to
statically link the library to your app.
To statically link a library, i'm pretty sure all you have to do is
include the
header files and make sure the library's files are in the right place
(which,
by the way, is where?).
Quick answer:
The traditional location for standard UNIX libraries is "/usr/lib". The
corresponding headers are usually in "/usr/include".
Longer answer:
The linker is not limited to a single directory; it uses a "search
path" to find libraries in much the same way that the command shell
uses one to find a command that you've typed in. You can add
directories to the library search path with the "-L" linker flag, and
to the header search path with the "-I" compiler flag.
Most GNU libraries, if you configure, compile, and install them
yourself, will by default install in "/usr/local/lib", and put their
headers in "/usr/local/include". However, you can usually use the
"--prefix" option to the "configure" script to change this. For
example, if you configure a library with the command "configure
--prefix=/stuff", that library's binary will be installed in
"/stuff/lib", and its headers in "/stuff/include".
Note that, when static linking is used, a copy of the library is stored
in the executable. There are no separate files to install on the end
users' machines, and the directory in which the library was installed
on the developer's machine is pretty much irrelevant.
To dynamically link a pre-installed library, what do i do?
Dynamic linking is the default on OS/X. To link statically, add the
"-static" option to the linker flags in Project Builder. This will only
work, of course, if static versions of the library exist; for many of
the standard libraries included with OS/X, there are only dynamic
libraries.
Do i need the
header files? Where do i put them?
Generally speaking, you always need the header files to compile your
application, and they're never needed by an end user. This is true
regardless of whether you use static or dynamic linking.
If you're linking against a library for which the headers have not been
installed, a good place to install them is in the library's
corresponding "include" directory. That is, if you find the library in
"/usr/lib", the headers would usually be found in "/usr/include".
That's just by convention, though; there's nothing to prevent you from
putting them anywhere you want, and if necessary using the "-I" flag to
tell the compiler where to find them.
For a comprehensive look at all of the options applicable to linking,
check out the "ld" man page. It's dry reading, and difficult going at
times - but it's worth the trouble.
sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.