I have been trying to generate random no using openssl api. I have this in my header: #include <openssl/rand.h> #include <openssl/ssl.h> Code is: result = RAND_bytes(buffer, 5); Compile it by: g++ -o test test.cpp -lssl I get the following errors: test.cpp.text+0x71): undefined reference to `RAND_bytes' collect2: ld returned 1 exit status Please help.