Ariyan
Ariyan

Reputation: 15158

crypto library not found in MinGW

I have a C code that uses openssl and crypto to do AES encryption.
It compiles in linux without problem.
But in windows and with MinGW it gives:

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lcrypto
collect2.exe: error: ld returned 1 exit status

I'm compiling using this:

gcc code.c -lcrypto -Ic:\OpenSSL-Win32\include -Lc:\mingw\msys\1.0\local\lib

What is the problem?

Upvotes: 1

Views: 4416

Answers (1)

jww
jww

Reputation: 102376

This is somewhat odd:

gcc code.c -lcrypto -Ic:\OpenSSL-Win32\include -Lc:\mingw\msys\1.0\local\lib

Try:

gcc code.c -Ic:\OpenSSL-Win32\include -Lc:\mingw\msys\1.0\local\lib -lcrypto

OpenSSL installs itself into /usr/local/ssl by default, which means your library is usually /usr/local/ssl/lib. Did you change it? I'm not sure what that translates to under MinGW.

Perhaps you could provide a ls of c:\mingw\msys\1.0\local\lib. If the library is not there, try to find it with find c:\mingw\msys\1.0\local -iname libcrypto.a (or libcrypto.so).

Upvotes: 1

Related Questions