Compiling and using libcurl in Windows/MinGW

2,525 views
Skip to first unread message

Claudia Neumann

unread,
Jun 16, 2012, 1:20:33 PM6/16/12
to harbou...@googlegroups.com
Hi all,

I want to share experiences to get libcurl compiled statically with hbcurl in
Windows/MinGW. I had some hard time to figure that out. In Linux that was no
problem. Some of these steps in Windows might not be required in the future.

First install MinGW with MSYS.
Get curl developement file, I got curl-7.26.0.tar.gz. Gunzip and untar and
install it in a directory which you can access with MSYS
(c:\mingw\home\claudia\curl).

In the file libcurl.pc.in add -DCURL_STATICLIB to Cflags.
If you don't need ldap, zlib or ssh2 support, do
./configure --prefix=<install directory> --disable-shared --disable-ldap --
without-zlib --without-libssh2
go for a meal (at least one item takes a long time, until verified)
make
make install
if make install has a problem in MSYS, copy libcurl.a to c:\mingw\lib and
\include\* to c:\mingw\include.

Install harbour in MSYS (c:\mingw\home\claudia\harbour)
Compile and install harbour with MSYS (at the moment harbour doesn't compile
contrib).
Go to c:\mingw\home\claudia\harbour\contrib\hbcurl
set HB_WITH_CURL=c:\mingw\include
set HB_CURL_STATIC=yes
hbmk2 hbcurls
-> libhbcurls.a is generated.
Copy libhbcurls.a to harbour-lib-directory (c:\mingw\lib\win\mingw) and
hbcurl.ch to harbour-include-directory (c:\mingw\include).

Compile your app with
-fullstatic
-lhbcurls
-lcurl

I hope I did not forget a step.

HTH

Claudia

Viktor Szakáts

unread,
Jun 16, 2012, 1:38:53 PM6/16/12
to harbou...@googlegroups.com
> Compile and install harbour with MSYS (at the moment harbour doesn't compile
> contrib).
> Go to c:\mingw\home\claudia\harbour\contrib\hbcurl
> set HB_WITH_CURL=c:\mingw\include
> set HB_CURL_STATIC=yes
> hbmk2 hbcurls
> -> libhbcurls.a is generated.
> Copy libhbcurls.a to harbour-lib-directory (c:\mingw\lib\win\mingw) and
> hbcurl.ch to harbour-include-directory (c:\mingw\include).

Note that libhbcurls is automatically generated as part
of the regular Harbour build process, if HB_WITH_CURL is set.

If you want to build or rebuild one specific contrib only,
like you did here, you can use also the "official" solution,
described here:
INSTALL/2. HOW TO DO A PARTIAL [RE]BUILD

> Compile your app with
> -fullstatic
> -lhbcurls
> -lcurl

-fullstatic won't make any difference on Windows, so it's
not needed. Instead of the other two it's enough to add hbcurl.hbc.

So these are the required hbmk2 options:
-env:HB_CURL_STATIC=yes hbcurl.hbc

Instead of -env:, you may use 'set HB_CURL_STATIC=yes'
before calling hbmk2, as you wrote.

-- Viktor

Claudia Neumann

unread,
Jun 16, 2012, 2:24:10 PM6/16/12
to harbou...@googlegroups.com, Viktor Szakáts
Hi Viktor
I did this, for you told me before. But it didn't work out for me.
My harbour app wouldn't compile because of several not fullfilled dependancies.
I compiled hbcurl in contrib\hbcurl, because Rev 17667 compilation broke at
hbide and did not compile hbcurl. Will try newest revision this evening.

Best regards

Claudia


Viktor Szakáts

unread,
Jun 16, 2012, 2:51:34 PM6/16/12
to Claudia Neumann, harbou...@googlegroups.com
Well, one reason might be that you build libcurl without
SSL support and the .hbc file tries to link against a libcurl
_with_ SSL support. Which means it might indeed not work
for you, unless you delete those libs from the .hbc file.

If a component doesn't build, just disable it using:
HB_BUILD_CONTRIBS=no hbide

-- Viktor

Claudia Neumann

unread,
Jun 16, 2012, 3:39:22 PM6/16/12
to Viktor Szakáts, harbou...@googlegroups.com
Hi Viktor,


Viele Grüße

Claudia Neumann
I could not extract this information from the .hbc files and I do not need SSL
support at the moment. Compiling only hbcurls.hbp succeeded.

> If a component doesn't build, just disable it using:
> HB_BUILD_CONTRIBS=no hbide

Where shall I put these commands? Typing the commands in every new MSYS is
boring. Can I put them into Makefile? Which is the exact syntax? It would help
for beginners to have the list from INSTALL for example in Makefile, where one
could change the path or say "no". Then tell in INSTALL to change it in
Makefile.

I did on command line in MSYS:
set HB_WITH_SQLITE3=no
and next time
set HB_BUILD_CONTRIBS=no sqlite3

->
SVN Rev. 17674:
! Building Harbour 3.2.0dev from source - http://harbour-project.org
! MAKE: make 3.81 /bin/sh
! HB_HOST_PLAT: win (x86) HB_SHELL: sh
! HB_PLATFORM: win (x86) (autodetected)
! HB_COMPILER: mingw (v44) (autodetected: /bin/)
! Component: 'zlib' found in /claudia/harbour/src/3rd/zlib (local)
! Component: 'pcre' found in /claudia/harbour/src/3rd/pcre (local)
! Component: 'gpm' not supported on win platform
! Component: 'slang' not found. Configure with HB_WITH_SLANG.
! Component: 'curses' not found. Configure with HB_WITH_CURSES.
! Component: 'x11' not found. Configure with HB_WITH_X11.
! Component: 'wattcp/watt-32' not supported on win platform

....

c:\Qt\mingw\claudia\harbour\bin\win\mingw\hbmk2 -quiet -width=0 @hbpre -inc
3rd/sqlite3/sqlite3.hbp @hbpost
../../../../../contrib/3rd/sqlite3/sqlite3.c: In function
'sqlite3AlterRenameTable':
../../../../../contrib/3rd/sqlite3/sqlite3.c:79219: internal compiler error:
Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
hbmk2: Error: Running C/C++ compiler. 1
! '3rd/sqlite3/sqlite3.hbp' returned status: 6
! Finished package build...
make[1]: [first] Error 6 (ignored)
./bin/win/mingw/hbmk2.exe ./config/postinst.hb first
! postinst script finished

I have not installed any sqlite3 developement files. What can I do?

Best regards

Claudia


Viktor Szakáts

unread,
Jun 16, 2012, 4:11:19 PM6/16/12
to Claudia Neumann, harbou...@googlegroups.com
Hi Claudia,

>> Well, one reason might be that you build libcurl without
>> SSL support and the .hbc file tries to link against a libcurl
>> _with_ SSL support. Which means it might indeed not work
>> for you, unless you delete those libs from the .hbc file.
>
> I could not extract this information from the .hbc files and I do not need SSL
> support at the moment. Compiling only hbcurls.hbp succeeded.

My bad, really meant LIBSSH2, not OpenSSL.

>> If a component doesn't build, just disable it using:
>>    HB_BUILD_CONTRIBS=no hbide
>
> Where shall I put these commands? Typing the commands in every new MSYS is
> boring. Can I put them into Makefile? Which is the exact syntax? It would help

This is simple envvar setting, so you can put it anywhere
envvar setting OS commands can be put, f.e. a batch file, bash
script, user login scripts. Again please refer to INSTALL,
because it's impossible for me to replicate its whole content
in personal answers, ie. there, it's written much precisely and
it should be used as reference instead my typo-ridden e-mails.

> for beginners to have the list from INSTALL for example in Makefile, where one
> could change the path or say "no". Then tell in INSTALL to change it in
> Makefile.

I don't plan to introduce automatic makefile generation UI, but
interested users can build such tool. Anyhow most of such
settings are only needed in rarer cases, and most of these
cases are unique, so it'd be hard to create a universal tool for it.

> I did on command line in MSYS:
> set HB_WITH_SQLITE3=no
> and next time
> set HB_BUILD_CONTRIBS=no sqlite3

sqlite3 is not a contrib, it's a 3rd party dependency, so
if you want to disable it, you should disable everything
that depends on it:
set HB_BUILD_CONTRIBS=no hbsqlit3 sddsqlt3

This should also work, I don't know why it doesn't, in your case:
set HB_WITH_SQLITE3=no

When you build any dependency, it should say f.e.:
! '../sddsqlt3/sddsqlt3.hbp' returned status: 10
where '10' means "missing dependency"

BTW, it's even better tactic to explicitly enable the
contribs you need. You will save build time.

-- Viktor

Viktor Szakáts

unread,
Jun 20, 2012, 4:22:27 AM6/20/12
to Claudia Neumann, harbou...@googlegroups.com
>   set HB_BUILD_CONTRIBS=no hbsqlit3 sddsqlt3
>
> This should also work, I don't know why it doesn't, in your case:
>   set HB_WITH_SQLITE3=no
>
> When you build any dependency, it should say f.e.:
>   ! '../sddsqlt3/sddsqlt3.hbp' returned status: 10
> where '10' means "missing dependency"
>
> BTW, it's even better tactic to explicitly enable the
> contribs you need. You will save build time.

HB_BUILD_CONTRIBS is the only option what you need
for this.

-- Viktor
Reply all
Reply to author
Forward
0 new messages