Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My compilation process throws around errors like

..undefined reference to `BN_cmp'

although I include <openssl/bn.h>

and run gcc -lssl -lcrypto test.c -o test

can someone help? (openssl libssl1.0.0, libssl-dev are installed)

share|improve this question

The solution is as simple as adding the -l flags at the end:

gcc test.c -o test -lssl -lcrypto

The order matters because ld since Ubuntu 11.04 is invoked with the -as-needed switch by default, so that files/libraries which depend on other libraries must come before these other libraries, i.e. test.c needs libcrypto, so it must come before -lcrypto.

For more information, see Toolchain Transition in Natty Narwhal.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.