mister
mister

Reputation: 3433

Unable to compile with openssl c++

I installed openssl through binaries and i have that exact files at that exact location. But when compiling i face this error. any idea?

g++ main.cpp -I /usr/local/openssl/include/openssl/ 
In file included from main.cpp:1:0:
main.h:4:25: fatal error: openssl/evp.h: No such file or directory
compilation terminated.

update:

the below command did the job but i still face errors.

g++ main.cpp -I/usr/local/openssl/include -L/usr/local/openssl/lib main.cpp -lcrypto

/usr/local/openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x1d): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x33): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x3d): undefined reference to `dlclose'

Any idea? :(


Solution :

g++ main.cpp -I/usr/local/openssl/include -L/usr/local/openssl/lib main.cpp -lcrypto -ldl

Upvotes: 3

Views: 4979

Answers (2)

hmjd
hmjd

Reputation: 121961

Change to:

g++ main.cpp -I /usr/local/openssl/include

as the include directive is including the name of the subdirectory.

Note you will have to add the openssl library to link with. I am not familiar with it but something like -lopenssl and add a directory to be searched to locate it using -L option. The full command would be something like (as I am guessing the lib directory and name of library for openssl):

g++ main.cpp -I/usr/local/openssl/include -L/usr/local/openssl/lib main.cpp -lopenssl

Upvotes: 3

djechlin
djechlin

Reputation: 60748

no space between -I and the path.

Upvotes: 0

Related Questions