使用OpenSSL for Windows进行交叉编译

时间:2009-08-05 17:11:29

标签: windows openssl mingw cross-compiling

我正在尝试编译oauth-utils http://mir.dnsalias.com/oss/oauth/start 适用于Ubuntu的Windows。我以前在Windows上编译过它 (几个月前),但想尝试交叉编译。

我使用mingw32确定openssl build,然后放入 libssl.a和libcrypto.a在正确的位置。链接器现在 找到这些库(耶!)但我收到以下错误:

/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xaac): undefined reference to `_CreateDCA@16'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xab9): undefined reference to `_CreateCompatibleDC@4'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xacc): undefined reference to `_GetDeviceCaps@8'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xadc): undefined reference to `_GetDeviceCaps@8'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xaf4): undefined reference to `_CreateCompatibleBitmap@12'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xb04): undefined reference to `_SelectObject@8'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xb18): undefined reference to `_GetObjectA@12'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xb81): undefined reference to `_BitBlt@36'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xb8c): undefined reference to `_GetBitmapBits@12'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xbe5): undefined reference to `_SelectObject@8'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xbec): undefined reference to `_DeleteObject@4'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xbf6): undefined reference to `_DeleteDC@4'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0xc00): undefined reference to `_DeleteDC@4'

任何可能导致此问题的想法?

感谢。

4 个答案:

答案 0 :(得分:4)

与Gdi32.lib链接

答案 1 :(得分:2)

您正在尝试编译哪个版本的OpenSSL? 一般来说,我发现版本1.0和更新版本的MinGW-W64工作得很好。 例如,参见OpenSSL cross-compilation for Windows教程。

答案 2 :(得分:1)

似乎如果删除了

之间的所有内容
static void readscreen(void)
{
#if !defined(OPENSSL_SYS_WINCE) && !defined(OPENSSL_SYS_WIN32_CYGWIN)

#endif /* !OPENSSL_SYS_WINCE */
}

在rand_win.c中,该建筑有效。我不是100%确定如何安全地删除它。

答案 3 :(得分:1)

您是否在链接命令中添加-mwindows?