strongSwan - Issue #1476
Linux to Windows crosscompile mingw64 openssl
21.05.2016 22:34 - Noel Kuntze

ステータス:

Closed

優先度:

Normal担当者:
カテゴリ:

windows

Affected version:

5.4.0

Resolution:

説明
Hello,I am trying to cross compile strongSwan 5.4.0 from Linux for Window.
For this purpose, I run the following command:

CC=x86̲64-w64-mingw32-gcc CFLAGS="-g -O2 -Wall -Wno-pointer-sign -Wno-format-security -Wno-format -mno-ms-bitfields -I
usr/include/" LDFLAGS="-L/home/thermi/FH-Stuff/UNITS-8/Bachelorarbeit/win32-libs/openssl/" ./configure --host=x86̲64-w64mingw32 --disable-defaults --enable-monolithic --enable-static --enable-svc --enable-ikev2 --enable-ikev1--enable-nonce --enab
pem --enable-pkcs1 --enable-x509 --enable-openssl --enable-socket-win --enable-kernel-wfp --enable-kernel-iph --enable-pubkey
enable-swanctl --with-swanctldir=swanctl --with-strongswan-conf=strongswan.conf
That fails, however, with the following message:[...]
checking for main in -lcrypto... no
configure: error: OpenSSL libcrypto notfoundAm I making a mistake or is this a problem with the source? libcrypto does not exist in the openssl libs for Windows. Instead,libeay32.dll and ssleay32.dll are provided.
履歴#1 - 22.05.2016 14:01 - Martin Willi- ステータス を New から Feedback に変更

libcrypto does not exist in the openssl libs for Windows. Instead, libeay32.dll and ssleay32.dll are provided.

Yes, and the configure script should check for libeay32 instead of libcrypto on Windows (seehttps://git.strongswan.org/?p=strongswan.git;a=blob;f=configure.ac#l783). For some reason the configure script does not detect a Windows build,check config.log for details what is going on.
-I/usr/include/

That is probably not what you want when cross-compiling. I'd recommend to use the instructions from the Windows page.
#2 - 22.05.2016 14:47 - Noel Kuntze
Martin Willi wrote:
libcrypto does not exist in the openssl libs for Windows. Instead, libeay32.dll and ssleay32.dll are provided.

Yes, and the configure script should check for libeay32 instead of libcrypto on Windows (seehttps://git.strongswan.org/?p=strongswan.git;a=blob;f=configure.ac#l783). For some reason the configure script does not detect a Windows
build, check config.log for details what is going on.

part of config.logpart of config.log

10.10.2024

1/4

configure:19276: checking for Windows target
configure:19292: x86̲64-w64-mingw32-gcc -c -g -O2 -Wall -Wno-pointer-sign -Wno-format-security -Wno-format -mno-ms-bitfields -I/usr/include/-I/usr/local/include conftest.c >&5
In file included from /usr/include/stdlib.h:314:0,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/mm̲malloc.h:27,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/xmmintrin.h:34,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/x86intrin.h:33,
from /usr/x86̲64-w64-mingw32/include/winnt.h:1521,
from /usr/x86̲64-w64-mingw32/include/minwindef.h:163,
from /usr/x86̲64-w64-mingw32/include/windef.h:8,
from /usr/x86̲64-w64-mingw32/include/windows.h:69,
from conftest.c:19:/usr/include/sys/types.h:109:19: error: conflicting types for 'ssize̲t'
typedef ̲ssize̲t ssize̲t;^˜˜˜˜In file included from /usr/x86̲64-w64-mingw32/include/excpt.h:9:0,
from /usr/x86̲64-w64-mingw32/include/windows.h:65,
from conftest.c:19:/usr/x86̲64-w64-mingw32/include/crtdefs.h:45:35: note: previous declaration of 'ssize̲t' was here
̲̲MINGW̲EXTENSION typedef ̲̲int64 ssize̲t;^˜˜˜˜In file included from /usr/include/sys/types.h:132:0,
from /usr/include/stdlib.h:314,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/mm̲malloc.h:27,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/xmmintrin.h:34,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/x86intrin.h:33,
from /usr/x86̲64-w64-mingw32/include/winnt.h:1521,
from /usr/x86̲64-w64-mingw32/include/minwindef.h:163,
from /usr/x86̲64-w64-mingw32/include/windef.h:8,
from /usr/x86̲64-w64-mingw32/include/windows.h:69,
from conftest.c:19:/usr/include/time.h:75:18: error: conflicting types for 'time̲t'
typedef ̲̲time̲t time̲t;^˜˜˜In file included from /usr/x86̲64-w64-mingw32/include/excpt.h:9:0,
from /usr/x86̲64-w64-mingw32/include/windows.h:65,
from conftest.c:19:/usr/x86̲64-w64-mingw32/include/crtdefs.h:138:20: note: previous declaration of 'time̲t' was here
typedef ̲̲time64̲t time̲t;^˜˜˜In file included from /usr/x86̲64-w64-mingw32/include/winsock.h:32:0,
from /usr/x86̲64-w64-mingw32/include/windows.h:92,
from conftest.c:19:/usr/x86̲64-w64-mingw32/include/̲timeval.h:10:8: error: redefinition of 'struct timeval'struct timeval^˜˜˜˜In file included from /usr/include/sys/select.h:45:0,
from /usr/include/sys/types.h:219,
from /usr/include/stdlib.h:314,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/mm̲malloc.h:27,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/xmmintrin.h:34,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/x86intrin.h:33,
from /usr/x86̲64-w64-mingw32/include/winnt.h:1521,
from /usr/x86̲64-w64-mingw32/include/minwindef.h:163,
from /usr/x86̲64-w64-mingw32/include/windef.h:8,
from /usr/x86̲64-w64-mingw32/include/windows.h:69,
from conftest.c:19:/usr/include/bits/time.h:30:8: note: originally defined here
struct timeval^˜˜˜˜In file included from /usr/x86̲64-w64-mingw32/include/winsock.h:36:0,
from /usr/x86̲64-w64-mingw32/include/windows.h:92,
from conftest.c:19:/usr/x86̲64-w64-mingw32/include/psdk̲inc/̲fd̲types.h:25:3: error: conflicting types for 'fd̲set'} fd̲set;^˜˜˜In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:314,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/mm̲malloc.h:27,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/xmmintrin.h:34,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/x86intrin.h:33,
from /usr/x86̲64-w64-mingw32/include/winnt.h:1521,
from /usr/x86̲64-w64-mingw32/include/minwindef.h:163,
from /usr/x86̲64-w64-mingw32/include/windef.h:8,
from /usr/x86̲64-w64-mingw32/include/windows.h:69,

10.10.2024

2/4

from conftest.c:19:/usr/include/sys/select.h:75:5: note: previous declaration of 'fd̲set' was here} fd̲set;^˜˜˜In file included from /usr/x86̲64-w64-mingw32/include/windows.h:92:0,
from conftest.c:19:/usr/x86̲64-w64-mingw32/include/winsock.h:299:34: error: conflicting types for 'select'
WINSOCK̲API̲LINKAGE int WSAAPI select(int nfds,fd̲set *readfds,fd̲set *writefds,fd̲set *exceptfds,const PTIMEVAL timeout);^˜˜˜In file included from /usr/include/sys/types.h:219:0,
from /usr/include/stdlib.h:314,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/mm̲malloc.h:27,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/xmmintrin.h:34,
from /usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/include/x86intrin.h:33,
from /usr/x86̲64-w64-mingw32/include/winnt.h:1521,
from /usr/x86̲64-w64-mingw32/include/minwindef.h:163,
from /usr/x86̲64-w64-mingw32/include/windef.h:8,
from /usr/x86̲64-w64-mingw32/include/windows.h:69,
from conftest.c:19:/usr/include/sys/select.h:106:12: note: previous declaration of 'select' was hereextern int select (int ̲̲nfds, fd̲set *̲restrict ̲̲readfds,^˜˜˜
configure:19292: $? = 1
configure: failed program was: ¦ /* confdefs.h */ ¦ #define PACKAGE̲NAME "strongSwan" ¦ #define PACKAGE̲TARNAME "strongswan" ¦ #define
PACKAGE̲VERSION "5.4.1dr1" ¦ #define PACKAGE̲STRING "strongSwan 5.4.1dr1" ¦ #define PACKAGE̲BUGREPORT "" ¦ #define PACKAGE̲URL"" ¦ #define PACKAGE "strongswan" ¦ #define VERSION "5.4.1dr1" ¦ #define CONFIG̲H̲INCLUDED /**/ ¦ #define LT̲OBJDIR ".libs/" ¦ #defineHAVE̲STDBOOL̲H 1 ¦ #define size̲t unsigned int ¦ #define HAVE̲ALLOCA̲H 1 ¦ #define HAVE̲ALLOCA 1 ¦ #define HAVE̲DECL̲STRERROR̲R 0¦ #define HAVE̲DLADDR /**/ ¦ /* end confdefs.h. */ ¦ #include <windows.h> ¦ int ¦ main () ¦ { ¦ #ifndef WIN32 ¦# error WIN32
undefined ¦#endif ¦ ¦ ; ¦ return 0; ¦ }configure:19308: result: no-I/usr/include/

That is probably not what you want when cross-compiling. I'd recommend to use the instructions from the Windows page.

I started out with the instructions from that page and just added the --host argument, together with the changed paths. I thought it did not matter
what openssl headers I chose, as long as they correspond with the DLLs. What is a good place to both get a recent openssl build for Windows
together with the headers of it?
#3 - 22.05.2016 15:30 - Martin Willi

from /usr/x86̲64-w64-mingw32/include/windows.h:69,/usr/include/sys/types.h:109:19: error: conflicting types for 'ssize̲t'The /usr/include includes clash with those provided by mingw. The wiki instructions add an include to the Windows openssl headers, but yourinclude points to the Linux include headers.
What is a good place to both get a recent openssl build for Windows together with the headers of it?

https://slproweb.com/products/Win32OpenSSL.html worked fine for me, but building it yourself is not that hard if you follow the OpenSSL
instructions.
#4 - 22.05.2016 16:24 - Noel Kuntze
Martin Willi wrote:
from /usr/x86̲64-w64-mingw32/include/windows.h:69,/usr/include/sys/types.h:109:19: error: conflicting types for 'ssize̲t'The /usr/include includes clash with those provided by mingw. The wiki instructions add an include to the Windows openssl headers, but yourinclude points to the Linux include headers.
What is a good place to both get a recent openssl build for Windows together with the headers of it?

https://slproweb.com/products/Win32OpenSSL.html worked fine for me, but building it yourself is not that hard if you follow the OpenSSL
instructions.

10.10.2024

3/4

Well, it actually is kind of hard, because there are no instructions for cross compiling it from Linux to Windows with mingw64 (which is required soI can actually link strongSwan against openssl).
#5 - 22.05.2016 20:02 - Noel Kuntze
I copied the libs and headers from the OpenSSL build from your link to a shared folder between a VM with that build installed and am trying tocross compiel them. It fails with the linker complaining about nof finding -leay32. The headers and the libs come from the same build, so I guess itwas built with VisualStudio, so I can not link against it with mingw64?
That's what the build.log says:/usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/../../../../x86̲64-w64-mingw32/bin/ld:/libeay32.dll when searching for -leay32/usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/../../../../x86̲64-w64-mingw32/bin/ld:/libeay32.dll when searching for -leay32

skipping

incompatible/home/thermi/VMs/win8.1-sharedfolder/skipping

incompatible/home/thermi/VMs/win8.1-sharedfolder/part of config.logpart of config.log
configure:21387: checking for main in -leay32
configure:21406: x86̲64-w64-mingw32-gcc -o conftest.exe -g -O2 -Wall -Wno-pointer-sign -Wno-format-security -Wno-format -mno-ms-bitfields-I/home/thermi/VMs/win8.1-sharedfolder/include -I/home/thermi/FH-Stuff/UNITS-8/Bachelorarbeit/openvpn/tap-driver/tap-windows6/src/ -I/usr/local/include-L/home/thermi/VMs/win8.1-sharedfolder/ -L/usr/local/lib conftest.c -leay32 >&5/usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/../../../../x86̲64-w64-mingw32/bin/ld: skipping incompatible/home/thermi/VMs/win8.1-sharedfolder//libeay32.dll when searching for -leay32/usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/../../../../x86̲64-w64-mingw32/bin/ld: skipping incompatible/home/thermi/VMs/win8.1-sharedfolder//libeay32.dll when searching for -leay32/usr/lib/gcc/x86̲64-w64-mingw32/6.1.1/../../../../x86̲64-w64-mingw32/bin/ld: cannot find -leay32
collect2: error: ld returned 1 exit statusconfigure:21406: $? = 1
configure: failed program was: ¦ /* confdefs.h */ ¦ #define PACKAGE̲NAME "strongSwan" ¦ #define PACKAGE̲TARNAME "strongswan" ¦ #define
PACKAGE̲VERSION "5.4.1dr1" ¦ #define PACKAGE̲STRING "strongSwan 5.4.1dr1" ¦ #define PACKAGE̲BUGREPORT "" ¦ #define PACKAGE̲URL"" ¦ #define PACKAGE "strongswan" ¦ #define VERSION "5.4.1dr1" ¦ #define CONFIG̲H̲INCLUDED /**/ ¦ #define STDC̲HEADERS 1 ¦ #define
HAVE̲SYS̲TYPES̲H 1 ¦ #define HAVE̲SYS̲STAT̲H 1 ¦ #define HAVE̲STDLIB̲H 1 ¦ #define HAVE̲STRING̲H 1 ¦ #define HAVE̲MEMORY̲H 1 ¦#define HAVE̲STRINGS̲H 1 ¦ #define HAVE̲INTTYPES̲H 1 ¦ #define HAVE̲STDINT̲H 1 ¦ #define HAVE̲UNISTD̲H 1 ¦ #define LT̲OBJDIR".libs/" ¦ #define HAVE̲̲BOOL 1 ¦ #define HAVE̲STDBOOL̲H 1 ¦ #define HAVE̲ALLOCA 1 ¦ #define HAVE̲DECL̲STRERROR̲R 0 ¦ #define
HAVE̲PTHREAD̲CONDATTR̲SETCLOCK 1 ¦ #define HAVE̲CONDATTR̲CLOCK̲MONOTONIC /**/ ¦ #define HAVE̲PTHREAD̲CONDATTR̲INIT 1¦ #define HAVE̲PTHREAD̲CANCEL 1 ¦ #define HAVE̲PTHREAD̲RWLOCK̲INIT 1 ¦ #define HAVE̲PTHREAD̲SPIN̲INIT 1 ¦ #defineHAVE̲SEM̲TIMEDWAIT 1 ¦ #define HAVE̲INT128 /**/ ¦ #define USE̲BUILTIN̲PRINTF /**/ ¦ /* end confdefs.h. */ ¦ ¦ ¦ int ¦ main () ¦ { ¦ returnmain (); ¦ ; ¦ return 0; ¦ }configure:21416: result: noconfigure:21421: error: OpenSSL libeay32 not found#6 - 23.05.2016 20:16 - Noel Kuntze
I succeeded in cross compiling openssl and linking strongSwan against it.
#7 - 24.05.2016 18:51 - Martin Willi- ステータス を Feedback から Closed に変更

10.10.2024

4/4