I am having trouble compiling and linking a program using OpenSSL under MinGW and a C++ compiler. These are my headers:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <openssl/rsa.h>
#include <openssl/engine.h>
#include <openssl/pem.h>
UPDATED (CHECK THE COMMENTS) :
I want compile it using MinGW so I first tried :
i686-w64-mingw32-g++ -o crypto_file_example base64.h en.cpp -lssl -lcrypto
But I got :
en.cpp:5:25: fatal error: openssl/rsa.h: No such file or directory
compilation terminated.
so i tried :
i686-w64-mingw32-g++ -o crypto_file_example base64.h en.cpp -I/usr/local/openssl/include/ /usr/local/openssl/lib/libssl.a /usr/local/openssl/lib/libcrypto.a /usr/lib/x86_64-linux-gnu/libdl.a
And here's another error came out :
/tmp/ccZGvNhw.o:en.cpp:(.text+0x5ec): undefined reference to `BIO_new_mem_buf'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x602): undefined reference to `BIO_set_flags'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x625): undefined reference to `PEM_read_bio_RSA_PUBKEY'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x633): undefined reference to `ERR_get_error'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x643): undefined reference to `ERR_error_string'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x65e): undefined reference to `BIO_free'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x67c): undefined reference to `BIO_new_mem_buf'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x6a2): undefined reference to `PEM_read_bio_RSAPrivateKey'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x6b0): undefined reference to `ERR_get_error'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x6c0): undefined reference to `ERR_error_string'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x6db): undefined reference to `BIO_free'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x6f1): undefined reference to `RSA_size'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x72a): undefined reference to `RSA_public_encrypt'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x740): undefined reference to `ERR_get_error'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x750): undefined reference to `ERR_error_string'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x776): undefined reference to `RSA_size'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x792): undefined reference to `RSA_size'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x7b9): undefined reference to `RSA_private_decrypt'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x7cf): undefined reference to `ERR_get_error'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x7df): undefined reference to `ERR_error_string'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x918): undefined reference to `OPENSSL_init_crypto'
/tmp/ccZGvNhw.o:en.cpp:(.text+0x9a4): undefined reference to `RSA_free'
/tmp/ccZGvNhw.o:en.cpp:(.text+0xa4c): undefined reference to `RSA_free'
collect2: error: ld returned 1 exit status
And by the way I installed OpenSSL by downloading it from openssl website and compiling it !
So any help ? Or new ideas to try ?