Linking in OpenSSL libcrypto Statically

Thread Tools Search this Thread
Top Forums Programming Linking in OpenSSL libcrypto Statically
# 8  
Old 07-01-2011
-lxxx means search for libxxx.a if static and if dynamic. It is just shorthand for the library name. traditionally, never a space.
# 9  
Old 07-01-2011
Actually, I downloaded libcrypto.a and then wrote:

g++ -o MyProg -lxxx -lyyy -lzzz -Bstatic -lcrypto

yet when I went to run it on another box, it still complained that it couldn't find How can this be?
# 10  
Old 07-01-2011

Don't think -Bstatic works quite right in gcc, it's just a compatibility option borrowed from the flags of some esoteric compiler.

You don't need to link in a .a as a library, you can use it just like an object file. (that's what an .a is, essentially -- except it can have more than one .o in it)

gcc myprogram.c /usr/lib/libcrypto.a -o myprogram

It will dynamically link the C runtimes and such dynamically but pull static functions from libcrypto.a as needed, just like it would another .c or .o file.

If you don't have libcrypto.a, you may need to install openssl-dev or whatever your distro hides it under.
# 11  
Old 07-01-2011
You might need -L to find it, too -- no find but dynamic found = dynamic. Hide the dynamic one.

If -Bstatic does not work, grep down the man page for static.

These are really ld options, I believe. Linker ld, language independent, checks out the .o from .a to go with your .o and makes the executable.
# 12  
Old 07-03-2011
Thanks, guys. I think I'll try to treat libcrypto.a as though it were one of my object files. I hope that something works soon, because otherwise, I'll have to find the libcrypto source and include it in my product. My company needs my work to go out the door soon. Again, thanks.
# 13  
Old 07-03-2011
Originally Posted by BrandonShw
Thanks, guys. I think I'll try to treat libcrypto.a as though it were one of my object files.
That's all that's in an .a file -- several .o files.
# 14  
Old 07-05-2011
Here is the result:

g++ -o Encode Encode06.o libcrypto.a

libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xafb): undefined reference to `dlopen'
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xb0f): undefined reference to `dlsym'
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xb25): undefined reference to `dladdr'
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xb31): undefined reference to `dlclose'
libcrypto.a(fips.o): In function `FIPSCHECK_verify':
(.text+0xb83): undefined reference to `dlclose'
collect2: ld returned 1 exit status
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Create shared libs on AIX (with certain libs which are statically linked)

I want to create a shared lib with certain libs statically linked to it. I can generate a fully shared lib as follows: gcc -maix64 -DHAVE_CONFIG_H -I. -I./src -DHAVE_OPENSSL -I/usr/include/openssl -I/usr/include -I/usr/include/apr-1 -D_LARGEFILE64_SOURCE -I/usr/java8_64/include -shared -o... (0 Replies)
Discussion started by: amandeepgautam
0 Replies

2. UNIX for Advanced & Expert Users

Curl: fatal:

Hi, I've installed curl with all despondency but when I try to start it I get: root@xxx> curl curl: fatal: open failed: No such file or directory Killed Looks like I have to change/make symlinks but I don't know how/where. Any idia? ---------- Post... (3 Replies)
Discussion started by: mehrdad68
3 Replies

3. Solaris

Hi Can anyone tell me the use of ? I know it is used for SSH. Also is there a way to look into the content of these jars? Also is there a way to uncompress the same? i tried # uncompress No such file or directory # jar xvf... (6 Replies)
Discussion started by: flinders1323
6 Replies

4. Programming

dlopen failing on library with statically linked dependencies

I am attempting to port a program from OS X to Linux. It's C++ & Qt Creator and I did the original Windows to OS X port, so I tried to make it as POSIX-compliant as possible; the OS X port works well, and the Linux port builds and starts (it's on Ubuntu 9.10) but has some issues running. The... (2 Replies)
Discussion started by: Hodapp87
2 Replies

5. Solaris

g++ linking problem...

I use Solaris 10, compiling with a custom g++ (3.4.6) and GNU binutils (2.17). Things have gone well on two different systems, but when I tried moving to a third, it all fell over. Basically, it is now using the CC linker, but I need to use options not available to it. I believe I have found the... (0 Replies)
Discussion started by: Elric of Grans
0 Replies

6. UNIX for Dummies Questions & Answers

is linking possible?

how would i link 2 files together? is it the same as copying? (1 Reply)
Discussion started by: trob
1 Replies

7. Programming

how to compile a program statically

how can i do static compilation in cc and -lldap i have system defined and user defined header file. Can any one suggest any site where from i can get some information about static and dynamic compilation. Thankx (1 Reply)
Discussion started by: bhakti
1 Replies

8. Programming

HOw to load dynamic lib from a statically linked program ?

I need to load a dynamic library from a statically linked program. Is there a way without recompiling my program. when i try to do that my program just crashes. If not possible, how can I avoid crashing the program when i try to load the dynamic lib, again without recompiling. If my... (1 Reply)
Discussion started by: disclaimer
1 Replies

9. Programming

Linking problem while linking to shared library

Hi I'm getting ld: fatal: option -h and building a dynamic executable are incompatible ld: fatal: Flags processing errors When I run ld -shared -L/usr/dt/lib -lDtSvc -o Workspace.o after running gcc -fPIC -I/usr/X11R6/include -I/usr/dt/include -c Workspace.c I'm... (6 Replies)
Discussion started by: laho
6 Replies
Login or Register to Ask a Question