<div dir="ltr"><div>Thank you for the suggestion. Will try that.<br></div><div><br></div><div>Regarding the static library, the term 'linking' I used was more tongue in cheek but nonetheless. However my current concern here is meeting libSSL and libCrypto's dependencies on host libraries on Linux platform. For instance, when I talked about 'linking' errors with respect to symbols like 'dlopen', so as I mentioned, I had to specify '-ldl' and '-lz' to the gcc linker that suggests a dynamic dependency on these platform libraries.<br><br>I was trying to understand the components that would be needed to package the whole shebang into an archive which I can later 'just run' on a similar Linux system that has been completely stripped down for purposes of size and speed<br><br></div>Is there a way to do that?<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 13, 2019 at 8:04 PM Michael Wojcik <<a href="mailto:Michael.Wojcik@microfocus.com">Michael.Wojcik@microfocus.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> From: openssl-users [mailto:<a href="mailto:openssl-users-bounces@openssl.org" target="_blank">openssl-users-bounces@openssl.org</a>] On Behalf Of Aijaz Baig<br>
> Sent: Wednesday, November 13, 2019 01:45<br>
<br>
> I am trying to statically link libssl.a and libcrypto.a into a static library of my own<br>
> which I will be using in an application (Linux).<br>
<br>
You can't link anything into a Linux static library, technically.<br>
<br>
ELF static libraries, like the older UNIX static libraries they're descended from, are just collections of object files, possibly with some additional metadata. (In BSD 4.x, for example, libraries often had an index member added using the ranlib utility, so that the linker didn't have to search the entire library for each symbol.)<br>
<br>
On some platforms, where objects can be relinked, the constituent object files produced by compiling source files are sometimes combined into a single large object. This is most often seen on AIX, which uses IBM's XCOFF object format (an enhanced COFF); XCOFF supports relinking objects, so you can bundle objects up this way and save some time in symbol resolution when you link against the library later. But even on AIX this is commonly seen with dynamic libraries and relatively rare for static ones.<br>
<br>
Normally the linker isn't even involved in creating a static library. You compile sources to objects, and then use ar(1) to create the static library. The makefile you posted to StackOverflow doesn't include this step, so it's hard to tell what exactly you're doing.<br>
<br>
But in any case, linking a static library against another static library is essentially a no-op.<br>
<br>
What you *can* do, if you don't want to have to list your library and the OpenSSL libraries when linking your application, is combine multiple static libraries into a single one - provided the object names don't conflict. This is straightforward:<br>
<br>
$ mkdir tmp; cd tmp<br>
$ ar x /path/to/libssl.a<br>
$ ar x /path/to/libcrypto.a<br>
$ cp /path/to/your/objects/*.o .<br>
$ ar c ../your-library.a *.o<br>
$ cd ..<br>
$ rm -rf tmp<br>
<br>
(Untested, but see the ar manpage if you run into issues.)<br>
<br>
That should create a single archive library containing all the objects from the three input libraries. Again, it relies on there being no filename clashes among the objects; if there are, you'll have to rename some of them.<br>
<br>
--<br>
Michael Wojcik<br>
Distinguished Engineer, Micro Focus<br>
<br>
<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><br>Best Regards,<div>Aijaz Baig</div></div></div>