On Sun July 17 2011, brandon...@aol.com wrote: > > I'll try changing the order of the libraries as you suggest. As for telling > the linker that I wanted a static link, I am doing the project in Eclipse and > put it in the flags area. It comes out in the compile: > > g++ ... -O3 -Wall -static -c -fmessage-length=0 > > I do want the executable to be as nearly self-contained as possible. Should > I do something to get it into the link statement as well? I don't honestly > know much about Linux, Eclipse, or OpenSSL, but I would like to learn. Do I > need the static flag both places? >
No. Only on the linker command line - usually in LDFLAGS variable. If your project manager (Eclipse) doesn't have a place for that, then you can have your call to g++ (the driver front end to the compiler, assembler and linker) pass the option to the linker by using: -Wl,<options>. You have it only on the compiler command line, where it isn't needed. In a command terminal window, you might try: g++ --help as a good starting point. ;-) And depending on your meaning of: "nearly self-contained as possible" you might want to only be doing a "partial link" to those libraries that you need to control the versions used. Then let the others be run-time linked (dynamic linked) by the loader. Mike PS: When totally lost about library order, try this model: lib3 lib2 lib1 lib0 lib1 lib2 lib3 Which is sometimes actually needed with inter-dependant libraries. (Which the driver front end is doing for you with the standard libraries.) Hint: put -W,-t into the linker's command line, let it tell you what it is doing. > Thanks to all of you for your continuing help. > > Brandon > > > > > -----Original Message----- > From: Michael S. Zick <open...@morethan.org> > To: openssl-users <openssl-users@openssl.org> > Sent: Sun, Jul 17, 2011 1:48 pm > Subject: Re: Trying to Link Statically to Libcrypto > > > On Sun July 17 2011, brandon...@aol.com wrote: > > Okay, I am in to my office for few minutes to get the details. Here is how > I > m compiling and linking, and the error message I am getting. I have placed > lipses (...) where the file and object names were. What do I need to do to > get > tatic linking to libcrypto.a to work? > > > g++ ... -O3 -Wall -static -c -fmessage-length=0 > > g++ -o ... -lz -lssl -lcrypto -lxml2 -lm -lldap > and get the error: > /usr/bin/ld: warning: libcrypto.so.8, needed by > /usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libssl.so, > ot found (try using -rpath or -rpath-link) > The linker is a "single pass" linker, symbols must be defined by > he library(ies) before then can be referenced (resolved). > I.E: Read message, then put -lcrypto __before__ -lssl > __order matters__ > And where did you tell the linker you wanted a static link? > Mike > /usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libldap.so: undefined > reference > o `RSA_generate_key' > /usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libldap.so: undefined > reference > o `DH_generate_parameters' > collect2: ld returned 1 exit status > > > > > > > > -----Original Message----- > From: brandonshw <brandon...@aol.com> > To: openssl-users <openssl-users@openssl.org> > Sent: Sat, Jul 16, 2011 11:40 am > Subject: Re: Trying to Link Statically to Libcrypto > > > Thanks. This is some very useful information and more than I knew. When I > et back to work on Monday, or possibly before if I go in for a few minutes, > I > ill send the full g++ command I am using as well as the error messages.. > > > > > > -----Original Message----- > From: Michael S. Zick <open...@morethan.org> > To: openssl-users <openssl-users@openssl.org> > Sent: Sat, Jul 16, 2011 6:53 am > Subject: Re: Trying to Link Statically to Libcrypto > > > On Sat July 16 2011, brandon...@aol.com wrote: > I am already linking in -lldap. Will -lopenldap work better? > > It is hard to say without seeing your full command input and > he output of where the linker is looking for libraries and > n what order. > __order matters__ > > > link to OpenSSL first, and then OpenLdap (order matters): > > gcc ... -lcrypto -lopenldap > If doing the linking with the compiler driver, add: > Wl,-t > o the command options so the linker will output each library > s it searches for symbols. > If calling the linker directly, just add: > t > o the link command options > The "-t" option is the "trace" option to the linker. > Mike > > Jeff > > _____________________________________________________________________ > penSSL Project http://www.openssl.org > ser Support Mailing List openssl-users@openssl.org > utomated List Manager majord...@openssl.org > > > > > _____________________________________________________________________ > penSSL Project http://www.openssl.org > ser Support Mailing List openssl-users@openssl.org > utomated List Manager majord...@openssl.org > > ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org