Reputation: 3433
I have downloaded the OpenSSL binary file. I would like to create a static library for my C++ program in Ubuntu. Meaning that they are in the same directory.
http://www.openssl.org/source/
Upvotes: 0
Views: 605
Reputation: 808
Add -static
parameter to gcc
when you are linking. I expect you want to static binary without any dynamic loaded libraries. In other case, add full path to libssl.a
as object file to linking in your build system. You have not specified how are you going to build your application.
Manually, you would use something like:
gcc -o application yourcode.c yourcode2.c /usr/lib/libssl.a
or better
gcc -static -o application yourcode.c yourcode2.c -lssl
Downloading binary for Linux is bad idea in most cases. If you want static binary, this should help. If you need custom build of library with special features, you need to download and build that library from sources yourself.
Anyway, similar question to yours is answered here at Static link of shared library function in gcc You might also check Linux static linking is dead? to discover there are maybe too many problems to even consider static linking.
And if you need more information about linking under Linux, check nice tutorial at http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
Upvotes: 2