Forum for iCal4OL, Print4OL and ICS4OL

Exchange of experiences / Erfahrungsaustausch / Get Help

You are not logged in.

Announcement

Verkauf von iCal4OL an Neukunden ist eingestellt! Keine Demo mehr verfügbar..
Diese Seite ist ausschliesslich für Kunden, welche auch noch zusätzliche Lizenzen kaufen können.
The selling of iCal4OL has ended! No trial available anymore..
This site is exclusively for customers, which may still want to buy additional licenses.

iCal4OL Version 2.16.6 is now available. See Announcements / Ankündigungen


#1 2016-05-27 19:05:17

Roland
Administrator
Registered: 2007-11-25
Posts: 1516

MinGW (W32): How-to to build W32 LibCurl.dll 7.49.0/7.48.0 with openssl-1.0.2h/SSL/SSPI (SSH/IDN/HTTP2)

I'm really a beginner with this! Two days to learn... and cleaning up on following days - with success!
Never used it before, but I wanted to update my older 7.40.0 libcurl stuff (Generic W32 from Günther Knauf).

My goal here was to get rid of the dependency to libgcc_s_dw2-1.dll (MinGW) in the newly build LibCurl DLLs, keeping program code untouched, supporting even older versions (by just replacing DLLs in program folder).

Perhaps this is helpful for you, too.
No warranties..

Sidebar (WinXP/iCal4OL):
- WinXP is dead, but libcurl.dll, linked with OpenSLL DLLs, can still connect to e.g. iCloud (DHE oder ECDHE cypher suite needed).
- iCal4OL has inbuild three HTTP libraries (WinInet, WinHttp and LibCurl). This way it can nearly run on every PC.
- (An exception are very strict firewalls, which do not allow WinSock DNS from LibCurl, where only WinInet.dll can/could work)
- (iCal4OL does newly support stunnel with no need to modify "hosts" file, using direct WinSock, with correct "Head:"-Header for e.g. iCloud -ask if interested)

First of all, deactivate e.g. Avira Antivirus. I had a lot of false positive in the whole process...

---
There is this very helpful page: http://www.gaia-gis.it/gaia-sins/mingw_how_to.html
This is working "ok" - some small issues - but with the dependency to libgcc_s_dw2-1.dll.
(Well, if you write your own software, it's actually better to use all stuff with dependencies = less memory usage. Here I don't care about thread-safe - not needed - but probably it's default?!)

This libgcc dll is a kind of a runtime library for gcc (for C functions not supported on target OS), which must be normally in C:\Windows\System32\ or must be loaded prior to other libraries (if you prefer a different path).

E.g. for VB6 in this order:

Code:

hCurlLib6 = LoadLibrary(App.Path & "\libgcc_s_dw2-1.dll")
hCurlLib5 = LoadLibrary(App.Path & "\libeay32.dll")  <== OpenSSL lib
hCurlLib4 = LoadLibrary(App.Path & "\ssleay32.dll")  <== OpenSSL lib
hCurlLib3 = LoadLibrary(App.Path & "\zlib1.dll")     <== zlib gzip/deflate
hCurlLib2 = LoadLibrary(App.Path & "\libcurl.dll")

hCurlLib1 = LoadLibrary(App.Path & "\vblibcurl.dll")   <== Visual Basic 6 and Office VBA bindings to libcurl - the last DLL to load

But my goal was to link libgcc_s_dw2-1.dll into every DLL (except of course vblibcurl.dll).
I had to google a lot, bloody Libtool (stripping link parameters), because for every package it works a little bit different.
See Libtool FAQ why.
For most packages "CC=gcc -static-libgcc" is the solution, which will be used here with MSYS "Export"-command (does set an environment variable).


Because html sites tend to vanish, I write here all necessary steps in my own English (I'm Swiss German).


1) Install MinGW (select incl. MSYS) - see http://www.mingw.org/wiki/Getting_Started for installation instruction of MinGW.
    Install Version gcc 4.9.3 or higher (supporting "autoconfig" by ./configure).

2) MSYS is a unix commandline window, started by C:\MinGW\msys\1.0\msys.bat   (you should already know this from 1)

3) Create a path C:\MinGW\msys\1.0\local\  .... in MSYS it's the: "cd  \usr\local"
Well, some subfolders you can already create, like "bin", "lib", "include".

Because of WinOS, additional tools are needed:
4) Download http://ftp.gnome.org/pub/gnome/binaries … _win32.zip
    unzip and copy pkg-config.exe to C:\MinGW\Bin
5) Download http://ftp.gnome.org/pub/gnome/binaries … _win32.zip
    unzip and copy liglib-2.0-0.dll to C:\MinGW\Bin
6) cd C:/MinGW/bin  ...and make a copy of libintl-8.dll as intl.dll: MSYS: cp libintl-8.dll intl.dll  (Explorer: copy libintl-8.dll intl.dll)


7) Building libzip (zlib1.dll)
Download http://zlib.net/zlib128.zip
Unzip into C:\MinGW\msys\1.0\local\zlib-1.2.8\

In MSYS :
==> use SHIFT-INSERT for (Copy)&Paste
==> use "make distclean" command in the package folder to repeat a configure/make!

Code:

cd /usr/local/zlib-1.2.8
export "INCLUDE_PATH=/usr/local/include"
export "LIBRARY_PATH=/usr/local/lib"
export "BINARY_PATH=/usr/local/bin"
export "CC=gcc -static-libgcc"
make -f win32/Makefile.gcc -e
make install -f win32/Makefile.gcc

Notes:
- Flag -e tells Makefile.gcc to accept the SET Variable "CC=gcc -static-libgcc"
- zlib has no configure file (for autoconfiguration file for ./configure, make, make install)

7b) Copy now from this folder to  (C:\MinGW\msys\1.0\) local/bin:
zlib1.dll

7c) Copy to local/lib  (was not done automatically!?!):
libz.a
libz.dll.a
(Not sure if relevant here - download http://ical.gutentag.ch/forum/img/libz.la and copy it to this folder, too)

7d) libz.h should be in local/include (check it - copy it from ../zlib-1.2.8/include).



8) Building openssl libeay32.dll, ssleay32.dll  (not needed but generated openssl.exe)
Download latest source, e.g. https://www.openssl.org/source/openssl-1.0.2h.tar.gz
You MUST untar(unzip) this in MSYS!
Therefore copy it to C:\MinGW\msys\1.0\local\

MSYS:

Code:

cd /usr/local
tar zxvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
unset CC
./Configure mingw --prefix=/usr/local shared -static-libgcc
make depend
make
make install

Copy generated *.dll into local/bin, check if  *.dll.a  *.a  are in local/lib  (should be ok - check it)
(e.g. libssl.dll.a is for ssleay32.dll: libcrypto.dll.a is for libeay32.dll)

Notes:
- One of the few "configure" where Libtool is not blocking "-static-libgcc"
- "CC=gcc -static-libgcc" is therefore not needed (could make trouble).



9) Building Curl.exe and libcurl.dll
Download Curl from https://curl.haxx.se/download.html
https://curl.haxx.se/download/curl-7.48.0.zip
..or
https://curl.haxx.se/download/curl-7.49.0.zip

MSYS:

Code:

cd /usr/local/curl-7.49.0
 ..or
cd /usr/local/curl-7.48.0

make distclean
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
export "CC=gcc -static-libgcc"

./configure --enable-shared=no --with-zlib=/usr/local/zlib-1.2.8 --enable-sspi --enable-libgcc [-without-libssh2 --without-nghttp2 --without-libidn]
make
make install-strip

make distclean
./configure --enable-shared=yes --with-zlib=/usr/local/zlib-1.2.8 --enable-sspi  [-without-libssh2 --without-nghttp2 --without-libidn]
make
make install-strip

Important:
If you follow the other posts (building e.g. libssh2.dll), you must disable eg. libssh2 support, otherwise they are automatically linked (OpenSSL is probably always needed):
==> --without-libssh2
==> --without-nghttp2
==> --without-libidn
You may want to try: ./configure --enable-shared=yes --with-zlib=/usr/local/zlib-1.2.8 --enable-sspi  --without-libssh2 --without-nghttp2 --without-libidn
==> --with-winidn=PATH ... needs probably Windows 7 at least.

Notes:
- Check if generated *.dll is in local/bin, *.dll.a *.a  in local/lib  (just check it)
- PKG_CONFIG_PATH (and xxFLAGS) tell the path to the /lib (and /include) files.
  If they are not there (zlib1 was not build with "make install[-silent] - I asked you to copy them manually), the path should be added as above = security!
- the second ./configure is for libcurl-4.dll, but it can't use --enable-libgcc, because it's itself a SHARED Library, but the "CC=gcc -static-libgcc" does the trick (libgcc dependency)!
- You can probably rename libcurl-4.dll to libcurl.dll for your project (seems to work, if you don't build other DLL/EXE which need libcurl-4.dll).
- Check file "configure" in this path for options like --with-winssl  aso.
  ./configure --help    will always show possible options!

I really can't give support for special configurations, but I will try to explain some in following posts with SSH2/IDN/HTTP2.

Not sure about the CA Cert bundle, though. I don't need it in my applications. ./Configure options are:

Code:

  --with-ca-bundle=FILE   Path to a file containing CA certificates (example:
                          /etc/ca-bundle.crt)
  --without-ca-bundle     Don't use a default CA bundle
  --with-ca-path=DIRECTORY
                          Path to a directory containing CA certificates
                          stored individually, with their filenames in a hash
                          format. This option can be used with OpenSSL, GnuTLS
                          and PolarSSL backends. Refer to OpenSSL c_rehash for
                          details. (example: /etc/certificates)
  --without-ca-path       Don't use a default CA path
  --with-ca-fallback      Use the built in CA store of the SSL library
  --without-ca-fallback   Don't use the built in CA store of the SSL library

Note: We are on Windows! I have no idea how to add the correct path. Does C:\xxxx\somwhere\ work?! I don't know..

I can give only an example for linux...
Create (find a mk-ca-bundle.vbs) or download an new ca-bundle.crt and copy it to e.g. /user/local
Then use to build libcurl-4.dll this line:

Code:

:
make distclean
./configure --enable-shared=yes --with-zlib=/usr/local/zlib-1.2.8 --enable-sspi --with-ca-bundle=/usr/local/ca-bundle.crt    [...other options..]
:

Result of my first build:

Code:

  curl version:     7.49.0
  Host setup:       i686-pc-mingw32
  Install prefix:   /usr/local
  Compiler:         gcc -static-libgcc
  SSL support:      enabled (OpenSSL)
  SSH support:      no      (--with-libssh2)
  zlib support:     enabled
  GSS-API support:  no      (--with-gssapi)
  TLS-SRP support:  enabled
  resolver:         default (--enable-ares / --enable-threaded-resolver)
  IPv6 support:     enabled
  Unix sockets support: no      (--enable-unix-sockets)
  IDN support:      no      (--with-{libidn,winidn})
  Build libcurl:    Shared=yes, Static=yes
  Built-in manual:  no      (--enable-manual)
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  SSPI support:     enabled
  ca cert bundle:   no
  ca cert path:     no
  ca fallback:      no
  LDAP support:     enabled (winldap)
  LDAPS support:    enabled
  RTSP support:     enabled
  RTMP support:     no      (--with-librtmp)
  metalink support: no      (--with-libmetalink)
  PSL support:      no      (libpsl not found)
  HTTP2 support:    disabled (--with-nghttp2)
  Protocols:        DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP


Download binaries curl-7.49.0-mingw32-(Open)SSL-SSPI.zip
You can rename libcurl-4.dll to libcurl.dll, if nothing is build later needing original file name.
Curl.exe (shared, needing DLLs) is included, too.

Last edited by Roland (2016-05-29 17:29:23)

Offline

 

#2 2016-05-28 08:02:06

Roland
Administrator
Registered: 2007-11-25
Posts: 1516

Re: MinGW (W32): How-to to build W32 LibCurl.dll 7.49.0/7.48.0 with openssl-1.0.2h/SSL/SSPI (SSH/IDN/HTTP2)

To compile (it with) libssh2-1.dll should be easy, too.

Note vor VB6: LoadLibrary(App.Path & "\libssh2-1.dll") .. should be done after loading zlib1.dll

10) Building  libssh2-1.dll
Download e.g. https://www.libssh2.org/download/libssh2-1.7.0.tar.gz from https://www.libssh2.org/download/
Copy it to usr/local

MSYS:
==> Note: Several SET stuff is normally "still" active, eg:
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
export "CC=gcc -static-libgcc"

Code:

cd /usr/local
tar zxvf libssh2-1.7.0.tar.gz
cd libssh2-1.7.0
make distclean
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
export "CC=gcc -static-libgcc"
./configure
make
make install-strip

Notes:
- This will create libssh2-1.dll
- Depending on the linker, you should check libcurl-4.dll later, if it tries to load libssh2-1.dll or libssh2.dll .. rename if necessary.

11) Now rebuild LibCurl with SSH Support
MSYS:

Code:

cd /usr/local/curl-7.49.0
 ..or
cd /usr/local/curl-7.48.0

export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
export "CC=gcc -static-libgcc"

# static stuff is actually not needed here... you may skip this..
make distclean
./configure --enable-shared=no --with-zlib=/usr/local/zlib-1.2.8 --with-libssh2=/usr/local/libssh2-1.7.0  --enable-sspi --enable-libgcc --without-nghttp2 --without-libidn
make
make install-strip

make distclean
./configure --enable-shared=yes --with-zlib=/usr/local/zlib-1.2.8 --with-libssh2=/usr/local/libssh2-1.7.0 --enable-sspi --without-nghttp2 --without-libidn
make
make install-strip

Note: PKG_CONFIG_PATH tells the path to the lib files. Not sure if "=/usr/local/xxxx" is correct, but it seems to be ignored.


Download binaries curl-7.49.0-mingw32-(Open)SSL-SSH-SSPI.zip

You can rename libcurl-4.dll to libcurl.dll, if nothing is build later needing original file name.
Curl.exe (shared, needing DLLs) is included, too.

Last edited by Roland (2016-05-28 09:24:17)

Offline

 

#3 2016-05-28 08:55:44

Roland
Administrator
Registered: 2007-11-25
Posts: 1516

Re: MinGW (W32): How-to to build W32 LibCurl.dll 7.49.0/7.48.0 with openssl-1.0.2h/SSL/SSPI (SSH/IDN/HTTP2)

Well, next step would be with IDN support by winidn or libidn-11.dll

What is IDN, see https://www.networking4all.com/en/domai … at+is+idn/

12) Probably the best ist to "configure" libcurl with flag: --with-winidn=PATH
Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1: http://www.microsoft.com/downloads/en/d … 607425a815



13) Building libidn-11.dll, for building libcurl  "--with-libiden"

TRICKY - Note: dependency to libgcc_s_dw2-1.dll is in the MinGW pre-build C:/MinGW/bin/libintl-8.dll... can't use directly
Again: My goal here is to get rid of libgcc_s_dw2-1.dll dependency!

In http://curl.haxx.se/gknw.net/7.40.0/dis … ingw32.zip is an older libidn-11.dll  with .a and .dll.a file.
If this is too complex, probably it's the best to use those.
==> .a .dll.a are in C:/MinGW/lib; .h in C:/MinGW/include)



13b) From Source:

Download http://ftp.gnu.org/gnu/libidn/libidn-1.32.tar.gz and copy it to usr/local
Same for http://ftp.gnu.org/pub/gnu/libiconv/lib … .14.tar.gz
Same for http://ftp.gnu.org/pub/gnu/gettext/gett … 9.7.tar.gz

MSYS:

Code:

cd /usr/local
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
export "CC=gcc -static-libgcc"
./configure
make
make install-strip

make distclean
export "CC=gcc -static-libgcc"
./configure --disable-shared
make
make install-strip

Notes:
- First step makes the DLLs (shared). CC=gcc -static-libgcc is perhaps not needed. Well if you need to unset it, use "unset CC"
- I don't need iconv.exe and libcharset-1.dll

Attention: libcharset.la and libiconv.la are corrupted, need other files..
Get http://ical.gutentag.ch/forum/img/libcharset.la
Get http://ical.gutentag.ch/forum/img/libiconv.la
Copy them to local/lib



13c) Building gettext
libintl is in (little part of) gettext - will compile a lot of stuff not needed! Should be optimized... too lazy.

MSYS:

Code:

cd /usr/local
tar zxvf gettext-0.19.7.tar.gz
cd gettext-0.19.7
make distclean
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
export "CC=gcc -static-libgcc"
./configure
make
make install-strip

Note: We have now two versions, MinGW pre-build and this.
LDFLAGS will point to usr/local/lib, but for linking shared it actually doesn't matter (probably the linker will look also in mingw/lib/).

I tried to static "in"-link the code of libintl.a and libiconf.a into libidn-11.dll (it's not a .exe), but I could not figure it out!
Some help, but still no idea how to do it here with "./configure" and FLAGs: http://stackoverflow.com/questions/1585 … with-mingw
Note: libintl-8.dll needs (shared) libiconv-2.dll, too.


13d) Building libidn:
MSYS

Code:

cd ..
tar zxvf libidn-1.32.tar.gz
cd libidn-1.32
make distclean
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"

# I link shared..
export "LDFLAGS=-L/usr/local/lib"
#Not working example for static: export "LDFLAGS=-lintl.a -Wl,-Bstatic -lconv.a -Wl,-Bstatic"
#Perhaps this works: export "LDFLAGS=-L/usr/local/lib -static"

export "CC=gcc -static-libgcc"

./configure  --enable-shared=yes --enable-static=yes --with-libiconv-prefix=/usr/local --with-libintl-prefix=/usr/local/
make
make install-strip

All three .dll therefore needed to load in e.g. VB6, in order:
LoadLibrary(libiconv-2.dll)
LoadLibrary(libintl-8.dll)
LoadLibrary(libidn-11.dll)

13e)
To rebuild libcurl, just add "--with-libidn" to ./configure line.

MSYS example:

Code:

cd /usr/local/curl-7.49.0
make distclean
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
export "CC=gcc -static-libgcc"

./configure --enable-shared=yes --with-zlib=/usr/local --enable-sspi --without-libssh2 --without-nghttp2 --with-libidn
make
make install-strip

Note: with zlib ssl sspi libidn, but without libssh2 and nghttp2 - only build libcurl.dll (and not static .a .dll.a)

And it's working now!

LoadLibraries in this order (if everything is linked, except 'ssh):

Code:

hCurlLib5 = LoadLibrary(App.Path & "\libeay32.dll")
hCurlLib4 = LoadLibrary(App.Path & "\ssleay32.dll")
hCurlLib3 = LoadLibrary(App.Path & "\zlib1.dll")
' hCurlLib6 = LoadLibrary(App.Path & "\libssh2-1.dll")
hCurlLib7 = LoadLibrary(App.Path & "\libiconv-2.dll")
hCurlLib8 = LoadLibrary(App.Path & "\libintl-8.dll")
hCurlLib9 = LoadLibrary(App.Path & "\libidn-11.dll")
hCurlLib2 = LoadLibrary(App.Path & "\libcurl.dll")
VB6: hCurlLib1 = LoadLibrary(App.Path & "\vblibcurl.dll")


Download binaries curl-7.49.0-mingw32-(Open)SSL-SSPI-IDN.zip

You can rename libcurl-4.dll to libcurl.dll, if nothing is build later needing original file name.
Curl.exe (shared, needing DLLs) is included, too.

Last edited by Roland (2016-05-29 17:54:32)

Offline

 

#4 2016-05-28 15:41:03

Roland
Administrator
Registered: 2007-11-25
Posts: 1516

Re: MinGW (W32): How-to to build W32 LibCurl.dll 7.49.0/7.48.0 with openssl-1.0.2h/SSL/SSPI (SSH/IDN/HTTP2)

14) Trying nghttp2 (HTTP2 support)

Download https://github.com/nghttp2/nghttp2/rele … 1.0.tar.gz and copy it to usr/local

MSYS:

Code:

cd /usr/local/
tar zxvf nghttp2-1.11.0.tar.gz
cd nghttp2-1.11.0
export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
export "CPPFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
export "CC=gcc -static-libgcc"
./configure
make
make install-strip

To rebuild libcurl, just add "--with-nghttp2" to ./configure

Example libcurl.dll with everything:
./configure --enable-shared=yes --with-zlib=/usr/local/zlib-1.2.8 --enable-sspi  --with-ssl=/usr/local/openssl-1.0.2h -with-libssh2=/usr/local/libssh2-1.7.0 --with-nghttp2=/usr/local/nghttp2-1.11.0 --with-libidn=/usr/local/libidn-1.32

Download binaries curl-7.49.0-mingw32-(Open)SSL-SSH-SSPI-IDN-HTTP2.zip
You can rename libcurl-4.dll to libcurl.dll, if nothing is build later needing original file name.
Curl.exe (shared, needing DLLs) is included, too.

Offline

 

Board footer