views:

144

answers:

3

I'm trying to statically link to libcrypto.a (from the openssl library) after building it from source with a new toolchain. However whenever I try to use any of the functions from that library, I keep receiving "undefined reference" errors. I've made sure the right header file was included. I've also double checked the symbol table of libcrypto.a and made sure these functions are indeed defined.

Is there anything else I can do to debug this error- like getting more info out of the linker or examining libcrypto.a itself, to find out why the linker is spitting out "undefined reference" error when the indicted symbols shows up in the symbol table?

+1  A: 

I see your post is tagged c++. OpenSSL is written in C.

Did you remember to do

extern "C" {
#include <various SSL files>
}

?

Andreas Bonini
Nope -- it already has those -- eg md5.h has a '#ifdef __cplusplus extern "C" { #endif' (over three lines) at the top.
Dirk Eddelbuettel
+1  A: 

grep the symbol out of libcrypto using nm

so you can see if its there - probably not (duh)

ssl has 2 libs , maybe you are using the wrong one

what exectly is the missing symbol

pm100
actually, calling any function inside libcrypto returned "undefined reference". I was focused on a random one
theactiveactor
+1  A: 

Undefined reference/symbol is a linker error indicating that the linker can't find the specified symbol in any of the object modules being linked. This indicates one or more of the following:

  1. The specified class/method/function/variable/whatever is not defined anywhere in the project.
  2. The symbol is inaccessible, probably due to an access specifier (in C++, doesn't apply to ANSI C)
  3. The reference is incorrect. This can be due to a spelling error or similar problem. (unlikely)
  4. You've neglected to include the required library in your build script when calling the linker.
David Lively