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.