Linking executable statically to OpenSSL

时间:2015-11-12 11:22:45

标签: c gcc openssl

I compiled OpenSSL and now I want to compile one of the examples from here and use the OpenSSL that I compiled.

When I link the libraries dynamically, everything works fine:

gcc dtls_udp_chargen.c -o example -ldl -lcrypto -lssl -lpthread

but when I try to compile the example with the OpenSSL version that I compiled by myself I get following output:

gcc dtls_udp_chargen.c openssl/libssl.a openssl/libcrypto.a -o example -ldl -lpthread
/tmp/cc3SIZpa.o: In function `THREAD_setup':
dtls_udp_chargen.c:(.text+0x102): undefined reference to `CRYPTO_set_id_callback'
/tmp/cc3SIZpa.o: In function `THREAD_cleanup':
dtls_udp_chargen.c:(.text+0x138): undefined reference to `CRYPTO_set_id_callback'
/tmp/cc3SIZpa.o: In function `connection_handle':
dtls_udp_chargen.c:(.text+0x146d): undefined reference to `ERR_remove_state'
collect2: error: ld returned 1 exit status

Any ideas what is the issue here ? Everything is run on linux of course.

0 个答案:

没有答案