Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems linking against OpenSSL with mingw

567 views
Skip to first unread message

Eystein Måløy Stenberg

unread,
Sep 20, 2009, 3:45:26 PM9/20/09
to
Hi all,
I manage to build OpenSSL beta3 successfully on two mingw
installations - one on 32 bit WinXP (mingw.org), and one on 64 bit
Vista (http://sourceforge.net/projects/mingw-w64/).
I use "./Configure mingw shared" and "./Configure mingw64 no-asm
no-shared", respectively (followed by make, make install).

However, the problem is that I can not link to *any* functions in the
openssl libraries...
I have this test-file, saved as "aes.c":
---
#include <openssl/evp.h>

int main()
{
EVP_aes_256_cbc();
return 0;
}
---

I try to compile it, on both mingw installations, with: "gcc
-I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto aes.c", which
gives:
---
C:\Users\Limit\AppData\Local\Temp\ccwPokzy.o:aes.c:(.text+0xe):
undefined reference to `EVP_aes_256_cbc'
collect2: ld returned 1 exit status
---

However, "nm /usr/local/ssl/lib/libcrypto.a | grep EVP_aes_256_cbc" gives:
---
0000000000000d50 T _EVP_aes_256_cbc
U _EVP_aes_256_cbc
---

So it seems like some relevant symbol are present (I tried calling
"_EVP_aes_256_cbc()" as well, without success)?
Or are they not properly exported?
Moreover, the exact same code and compile command successfully
compiles on a linux box with openssl version 0.9.7a.

I have spent a lot of time on this, and any inputs would be greatly appreciated.

Thank you.

Regards,
Eystein
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org

Jeremy Farrell

unread,
Sep 20, 2009, 7:08:02 PM9/20/09
to
> From: Eystein M=E5l=F8y Stenberg
>=20

> I manage to build OpenSSL beta3 successfully on two mingw
> installations - one on 32 bit WinXP (mingw.org), and one on 64 bit
> Vista (http://sourceforge.net/projects/mingw-w64/).
> I use "./Configure mingw shared" and "./Configure mingw64 no-asm
> no-shared", respectively (followed by make, make install).
>=20

> However, the problem is that I can not link to *any* functions in the
> openssl libraries...
>
> ...
>=20

> I try to compile it, on both mingw installations, with: "gcc
> -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto aes.c", which
> gives:
> ---
> C:\Users\Limit\AppData\Local\Temp\ccwPokzy.o:aes.c:(.text+0xe):
> undefined reference to `EVP_aes_256_cbc'
> collect2: ld returned 1 exit status
> ---

Try linking against libcrypto ;).

"gcc -I/usr/local/ssl/include -L/usr/local/ssl/lib ses.c -lcrypto"

might work.

Dave Thompson

unread,
Sep 20, 2009, 8:57:15 PM9/20/09
to
> From: owner-ope...@openssl.org On Behalf Of Eystein M=E5l=F8y =
Stenberg
> Sent: Sunday, 20 September, 2009 15:13
<snip: simple example>
> I try to compile it, on both mingw installations, with: "gcc=20

> -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto aes.c", which
> gives:
> ---
> C:\Users\Limit\AppData\Local\Temp\ccwPokzy.o:aes.c:(.text+0xe):
> undefined reference to `EVP_aes_256_cbc'
> collect2: ld returned 1 exit status
> ---
>=20
The 'gcc' linker (ld) (and AFAIK most others) is order sensitive.
You must have -lcrypto *after* the module(s) that calls it. (Though=20
*compiling* with -I after the code that #include's them is fine!)

> Moreover, the exact same code and compile command=20


> successfully compiles on a linux box with openssl version 0.9.7a.

>=20
Are you sure about the command? With gcc? That would surprise me.

Eystein Måløy Stenberg

unread,
Sep 21, 2009, 2:59:18 AM9/21/09
to
You nailed it.
"gcc -I/usr/local/ssl/include -L/usr/local/ssl/lib aes.c -lcrypto"
works perfectly.
However, on Red Hat, it compiles and links no matter where I put the
input file (checked it again).

Thank you very much!

-Eystein

On Mon, Sep 21, 2009 at 12:30 AM, Dave Thompson
<dave.t...@princetonpayments.com> wrote:
>> From: owner-ope...@openssl.org On Behalf Of Eystein M=E5l=F8y Ste=


nberg
>> Sent: Sunday, 20 September, 2009 15:13
> <snip: simple example>
>> I try to compile it, on both mingw installations, with: "gcc

>> -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto aes.c", which
>> gives:
>> ---
>> C:\Users\Limit\AppData\Local\Temp\ccwPokzy.o:aes.c:(.text+0xe):
>> undefined reference to `EVP_aes_256_cbc'
>> collect2: ld returned 1 exit status
>> ---
>>

> The 'gcc' linker (ld) (and AFAIK most others) is order sensitive.
> You must have -lcrypto *after* the module(s) that calls it. (Though

> *compiling* with -I after the code that #include's them is fine!)
>
>> Moreover, the exact same code and compile command

>> successfully compiles on a linux box with openssl version 0.9.7a.
>>

> Are you sure about the command? With gcc? That would surprise me.
>
>
>
> ______________________________________________________________________

> OpenSSL Project =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 http://www.openssl.org
> User Support Mailing List =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0openssl-=
us...@openssl.org
> Automated List Manager =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 majo...@openssl.org

Dave Thompson

unread,
Sep 22, 2009, 5:03:23 PM9/22/09
to
> From: owner-ope...@openssl.org On Behalf Of Eystein M=E5l=F8y =
Stenberg
> Sent: Monday, 21 September, 2009 02:59

> You nailed it.
> "gcc -I/usr/local/ssl/include -L/usr/local/ssl/lib aes.c -lcrypto"
> works perfectly.

> However, on Red Hat, it compiles and links no matter where I=20


> put the input file (checked it again).

> On Mon, Sep 21, 2009 at 12:30 AM, Dave Thompson=20
> <dave.t...@princetonpayments.com> wrote:

> > The 'gcc' linker (ld) (and AFAIK most others) is order sensitive.

> > You must have -lcrypto *after* the module(s) that calls it. <snip>

On further checking, I realized it's different for static versus=20
dynamic/shared linking; the latter works anywhere (even first).
You apparently got dynamic built-in on Linux, but static=20
in your own build. Sorry for being partly off.

0 new messages