0

I've been working with OpenSSL recently, and I ran into an issue issue which was fixed. However, upon fixing that problem, another separate problem surfaced.

I can only assume that this is a Linker Error. I haven't really had to deal with this sort of stuff before, and I'm not familiar with OpenSSL, so I don't really know how to link what I need (assuming that's even the issue).

Here's what happens:

gcc example.cpp -o example.out

/tmp/ccwBWhub.o: In function `main`:
example.cpp:(.text+0x91): undefined reference to 'OpenSSL_add_all_digests'
example.cpp:(.text+0xa2): undefined reference to 'EVP_get_digestbyname'
example.cpp:(.text+0xd7): undefined reference to 'EVP_MD_CTX_create'
example.cpp:(.text+0xf7): undefined reference to 'EVP_DigestInit_ex'
example.cpp:(.text+0x131): undefined reference to 'EVP_DigestUpdate'
example.cpp:(.text+0x16b): undefined reference to 'EVP_DigestUpdate'
example.cpp:(.text+0x187): undefined reference to 'EVP_DigestFinal_ex'
example.cpp:(.text+0x192): undefined reference to 'EVP_MD_CTX_destroy'
example.cpp:(.text+0x1ee): undefined reference to 'EVP_cleanup'

To my knowledge, this means that the compiler can't find where these functions are defined. From my research, online, I need to link it with the OpenSSL library, wherever that is.

I use #include <openssl/evp.h> to load in those functions (From my Source Code), so I assume I need to find that file. After running a search, I found the all of the include files in ~/program/openssl-1.0.1/include/openssl, where my program is at ~/program/example.cpp.

I tried linking it thusly: gcc -I./openssl-1.0.1/include/openssl example.cpp -o example.out, but it didn't work.

I can only assume that I have no idea what I'm doing, and that I don't know how to link files correctly. Hopefully someone here can help me out.

Community
  • 1
  • 1
Boom
  • 2,465
  • 4
  • 19
  • 21
  • add `-lcrypto` to your command line to link against libcrypto.so – Alex Díaz Apr 02 '15 at 18:01
  • Did you not read the documentation? Or the chapter in your book about using libraries? – Lightness Races in Orbit Apr 02 '15 at 18:01
  • The most I've ever had to do was link multiple .cpp files that were in the same directory. I've never had to use an open source library like this before. As for the documentation, I'd love a link to it, as I've been searching around for it, and I'm not working with any books. – Boom Apr 02 '15 at 18:10
  • Fixed it with -lssl and -lcrypto tags. I never would have guess that, and the duplicate question didn't help either. – Boom Apr 03 '15 at 05:00

0 Answers0