Re: PLEASE HELP - How do I include OpenSSL in my code?
- From: Ben C <spamspam@xxxxxxxxx>
- Date: 12 May 2006 21:46:05 GMT
On 2006-05-12, cpptutor2000@xxxxxxxxx <cpptutor2000@xxxxxxxxx> wrote:
Could some C guru please help me? I have a simple piece of code as:
#include <stdio.h>
#include <stdlib.h>
#include <openssl/rand.h>
int main(){
unsigned char temp[4];
RAND_bytes(temp, 4);
return 0;
}
If I type: whereis openssl
I get: openssl: /usr/bin/openssl /usr/include/openssl
/usr/share/man/man1/openssl.1ssl.gz
I compile this as:
gcc -g -o test test.c -I/usr/include/openssl -L/usr/bin/openssl
I get a linker error message as :
/tmp/cc4tQEqd.o(.text+0x1af0): In function `main':
/home/ecelrc/students/abanerj/cpp/test.c:6: undefined reference to
`RAND_bytes'
Could someone please point out what I am doing wrong? Any help would be
greatly
appreciated.
You need -l.
-L tells gcc where to look for libraries, -l tells it what libraries to
look in for symbols.
-lxxx means "look for a library called libxxx.a in the usual places".
You add places to "the usual places", if necessary, with -L.
The library you want is libssl.a and is quite likely in /usr/lib, where
gcc looks anyway, so -lssl with no -L option will probably do the trick:
$ gcc -g -o test test.c -I/usr/include/openssl -lssl
or also add -L/usr/lib/openssl (or something, depending on where
libssl.a is on your system) if you need it.
(gnu.gcc.help is the right NG for this by the way).
.
- References:
- PLEASE HELP - How do I include OpenSSL in my code?
- From: cpptutor2000@xxxxxxxxx
- PLEASE HELP - How do I include OpenSSL in my code?
- Prev by Date: Re: PLEASE HELP - How do I include OpenSSL in my code?
- Next by Date: Re: Array and Pointer Tutorial
- Previous by thread: Re: PLEASE HELP - How do I include OpenSSL in my code?
- Next by thread: Writting Pluggins
- Index(es):
Relevant Pages
|