How to compile .c file with OpenSSL includes?

前端 未结 7 902
醉梦人生
醉梦人生 2020-11-27 03:40

I am trying to compile a small .c file that has the following includes:

#include 
#include 
#include 

        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 04:05

    If the OpenSSL headers are in the openssl sub-directory of the current directory, use:

    gcc -I. -o Opentest Opentest.c -lcrypto
    

    The pre-processor looks to create a name such as "./openssl/ssl.h" from the "." in the -I option and the name specified in angle brackets. If you had specified the names in double quotes (#include "openssl/ssl.h"), you might never have needed to ask the question; the compiler on Unix usually searches for headers enclosed in double quotes in the current directory automatically, but it does not do so for headers enclosed in angle brackets (#include ). It is implementation defined behaviour.

    You don't say where the OpenSSL libraries are - you might need to add an appropriate option and argument to specify that, such as '-L /opt/openssl/lib'.

提交回复
热议问题