curl ssl FiveTechSoft Harbour_builder

835 views
Skip to first unread message

Eric Lendvai

unread,
Mar 27, 2022, 1:05:01 AM3/27/22
to Harbour Users
I am trying to use curl from within Harbour. For that reason I was looking at the following git builder:

But it seems its artifacts actually do not include hbcurl.

Looking at the pattern in the harbour_mingw_64.yml I even tried to build the libs with the following batch files, to be execute in a shell having Harbour and C compiler available.
(Windows 10 64-bit Mingw64)

Dear Antonio Linares, if you see this message, could you check the yml file, maybe I am missing something?

Or could anyone provide some working scripts to build hbcurl with ssl support?
Thanks.


if %HB_PATH%. == . goto MissingHB_PATH

SET HB_BUILD_MODE=c
SET HB_USER_PRGFLAGS=-l-
SET HB_BUILD_CONTRIBS=yes
SET HB_WITH_OPENSSL=c:/OpenSSL-Win64/include/
SET HB_WITH_CURL=c:/ProgramData/chocolatey/lib/curl/tools/curl-7.82.0-win64-mingw/include/  
SET HB_OPENSSL_STATIC=yes        
SET HB_STATIC_OPENSSL=yes        
SET HB_STATIC_CURL=yes    
SET HB_STATIC_OPENSSL=yes
SET HB_STATIC_CURL=yes
SET HB_COMPILER=mingw64
SET HB_BUILD_CONTRIB_DYN=yes
SET HB_BUILD_DYN=yes
c:
cd \Harbour\contrib\hbssl
hbmk2 ..\make.hb clean
hbmk2 ..\make.hb
cd \Harbour\contrib\hbcurl
hbmk2 ..\make.hb clean
hbmk2 ..\make.hb
goto End
:MissingHB_PATH
echo Run a HarbourTerminal Batch file first.
:End


FYI, I added support in datawharf to have REST endpoints. This is another example of how to make Harbour a REST API provider/server.

Baxajaun

unread,
Mar 27, 2022, 12:10:34 PM3/27/22
to Harbour Users
Hi Eric !

This is my script to build Harbour with OpenSSL and cURL.

---
REM MinGW 11.2 32 bits
set PATH=%PATH%;F:\Develop\CCompilers\WinLibs\V11\32bits\mingw32\bin;F:\TMP\Harbour\curl;F:\TMP\Harbour\curl\lib;F:\TMP\Harbour\curl\bin;F:\TMP\Harbour\curl\include;
set PATH=%PATH%;F:\TMP\Harbour\openssl;F:\TMP\Harbour\openssl\lib;F:\TMP\Harbour\openssl\lib\MinGW;F:\TMP\Harbour\openssl\include\openssl;F:\TMP\Harbour\openssl\engines-1_1;F:\TMP\Harbour\openssl\bin
set HB_INSTALL_PREFIX=F:\TMP\Harbour\MinGW
set HB_PLATFORM=win
set HB_COMPILER=mingw
set HB_STATIC_CURL=yes
set HB_STATIC_OPENSSL=yes
set HB_TIP_OPENSSL=yes
SET HB_HAS_OPENSSL=yes
SET HB_WITH_CURL=F:\TMP\Harbour\curl\include
set HB_WITH_OCILIB=f:\ocilib\include
SET HB_WITH_OPENSSL=F:\TMP\Harbour\openssl\include
REM set HB_WITH_SSH=F:\Develop\Harbour-Source\SSH\32\include
SET HB_BUILD_CONTRIB_DYN=yes
SET HB_BUILD_DYN=yes
set HB_TRACE=yes
set HB_BUILD_VERBOSE=yes
set HB_REBUILD_EXTERN=yes

win-make clean install > logMinGW11232.txt 2>&1

---

I hope this helps you.

Kind regards,

Eric Lendvai

unread,
Mar 28, 2022, 12:24:48 AM3/28/22
to Harbour Users
Thanks Baxajaun,

I am developing using 64bit, but I am willing to try the 32 bit just to see if it can work.

Could you let me know where you download the openssl and curl lib from? 
All the problems I am getting are around the bindings with hbssl and openssl it seems.

I modified hbssl.hbc by adding a like libpaths=C:/OpenSSL-Win64/lib/
and adding "lib" in front of "ssl" and "crypto" in the following 2 lines:
{!HB_DYNBIND_OPENSSL&!(HB_STATIC_OPENSSL&!hbdyn)&allmingw}libs=libssl libcrypto
{!HB_DYNBIND_OPENSSL& (HB_STATIC_OPENSSL&!hbdyn)&allmingw}libs=libssl libcrypto

I even tried to not make it static, but still a nightmare.

Now I am getting:
C:\Harbour\bin\win\mingw64\hbmk2 -quiet -width=0 -autohbm- @../hbpre -inc ../hbssl/hbssl.hbp @../hbpost
hbmk2: Created import library: ..\..\lib\win\mingw64\liblibcrypto-1_1-x64.a <= c:\OpenSSL-Win64\bin\libcrypto-1_1-x64.dll
hbmk2: Created import library: ..\..\lib\win\mingw64\liblibssl-1_1-x64.a <= c:\OpenSSL-Win64\bin\libssl-1_1-x64.dll
C:\Harbour\bin\win\mingw64\hbmk2 -quiet -width=0 -autohbm- @../hbpre -inc -hbdyn ../hbssl/hbssl.hbp @../hbpost ../hbssl/hbssl.hbc
../../bin/win/mingw64/.hbmk/hbssl-32-x64/hbdyn/bio.o:bio.c:(.text+0x1b): undefined reference to `hb_itemFreeCRef'
../../bin/win/mingw64/.hbmk/hbssl-32-x64/hbdyn/bio.o:bio.c:(.text+0x100d): undefined reference to `hb_itemGetCRef'
../../bin/win/mingw64/.hbmk/hbssl-32-x64/hbdyn/bio.o:bio.c:(.text+0x1a58): undefined reference to `hb_socketNToHS'
collect2.exe: error: ld returned 1 exit status
hbmk2[hbssl]: Error: Running dynamic lib link command. 1
hbmk2[hbssl]: Exit status: 7: failed in final assembly (linker or library manager)

Adding support for curl ssl into Harbour is so difficult. No wonder so few people want to choose Harbour with interop with other systems. 
But the REST API method would also make it so much easier to develop decentralized pure Harbour apps.

Mario H. Sabado

unread,
Mar 28, 2022, 4:08:20 AM3/28/22
to 'elch' via Harbour Users
Hi Eric,

In my case, I just reference the HB_WITH_CURL in msys64.

Regards,
Mario

image.png



--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/14434744-7546-4ebe-9027-f0bcf4fdbd43n%40googlegroups.com.

Eric Lendvai

unread,
Mar 28, 2022, 4:10:58 AM3/28/22
to Harbour Users
Update to my initial post.

I used the libs created by using the following github build originally create by Antonio Linares:

Create the following simple curl001.prg file:
======================================================================
#require "hbcurl"
Function Main()
? curl_version()
return nil
======================================================================
With the following simple curl001.hbp file:
======================================================================
#To target the creation of an exe
-hbexe

#To only recompile changed files
-inc

#To display compiler and linker info
-trace

#Output video driver for console app
-gtcgi

-o${CCompiler}\${BuildMode}\${EXEName}
debugger.hbm

-LC:\OpenSSL-Win64\lib\
-LC:\ProgramData\chocolatey\lib\curl\tools\curl-7.82.0-win64-mingw\lib\

#List below the source files to compile

hbcurl.hbc

Curl001.prg
======================================================================

And I am getting the following message: Note the cannot find -llibcurl
Even though the folder C:\ProgramData\chocolatey\lib\curl\tools\curl-7.82.0-win64-mingw\lib has the file libcurl.a and libcurl.dll.a

This seems to be such a basic problem. I would be really thankful for any help.


hbmk2: Processing environment options: -comp=mingw64
hbmk2: Compiling Harbour sources...
hbmk2: Harbour compiler command (built-in):
(C:\Harbour\bin\win\mingw64\harbour.exe) -n2 Curl001.prg -DHBMK_HAS_HBCURL=1 -dDONOTINCLUDE -dDEBUGVIEW -omingw64\release\.hbmk\win\mingw64\ -iC:\Harbour\include -iC:\Harbour\contrib\hbcurl -u+C:\Harbour\contrib\hbcurl\hbcurl.ch
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Compiling 'Curl001.prg'...
Lines 7, Functions/Procedures 1
Generating C source output to 'mingw64\release\.hbmk\win\mingw64\Curl001.c'... Done.
hbmk2: Compiling...
hbmk2: C/C++ compiler command:
gcc.exe -c -O3  -W -Wall -pipe -IC:/Harbour/include -IC:/Harbour/contrib/hbcurl ../../../../../mingw64/release/.hbmk/win/mingw64/Curl001.c
hbmk2: Linking... mingw64\release\Curl001.exe
hbmk2: Linker command:
gcc.exe mingw64/release/.hbmk/win/mingw64/Curl001.o mingw64/release/.hbmk/win/mingw64/_hbmkaut_Curl001.o    -mconsole -static -Wl,--start-group -lhbcurl -llibcurl -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainstd -lwinmm -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib   -Wl,--end-group -omingw64/release/Curl001.exe  -LC:/Harbour/lib/win/mingw64 -L"C:/OpenSSL-Win64/lib" -L"C:/ProgramData/chocolatey/lib/curl/tools/curl-7.82.0-win64-mingw/lib"
C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llibcurl

collect2.exe: error: ld returned 1 exit status
hbmk2[Curl001]: Error: Running linker. 1
gcc.exe mingw64/release/.hbmk/win/mingw64/Curl001.o mingw64/release/.hbmk/win/mingw64/_hbmkaut_Curl001.o    -mconsole -static -Wl,--start-group -lhbcurl -llibcurl -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainstd -lwinmm -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib   -Wl,--end-group -omingw64/release/Curl001.exe  -LC:/Harbour/lib/win/mingw64 -L"C:/OpenSSL-Win64/lib" -L"C:/ProgramData/chocolatey/lib/curl/tools/curl-7.82.0-win64-mingw/lib"
Failed To build "mingw64\release\Curl001.exe"

Antonio Linares

unread,
Mar 28, 2022, 5:35:36 AM3/28/22
to Harbour Users
Dear Eric,

Please try it using -lcurl only

best regards,

José M. C. Quintas

unread,
Mar 28, 2022, 9:44:00 AM3/28/22
to harbou...@googlegroups.com

Eric Lendvai

unread,
Mar 28, 2022, 4:20:40 PM3/28/22
to Harbour Users
Thanks Antonio for the suggestions.
I am now getting the 2 errors:

C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcurl

C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llibcurl

Would you be open for a meeting ?
Eric

Antonio Linares

unread,
Mar 29, 2022, 1:58:44 AM3/29/22
to Harbour Users
Dear Eric,

>  Would you be open for a meeting ?

yes, sure

Ash

unread,
Mar 29, 2022, 10:52:11 AM3/29/22
to Harbour Users
Hello Eric,

I built curl001.exe using the following method. All the required libraries are in C:\hb32\comp\mingw\bin folder.

No changes to curl001.prg. 

curl001.hbp
==============
hbcurl.hbc
Curl001.prg
==============

set path=C:\hb32\comp\mingw\bin;%path%  
hbmk2 curl001.hbp

Output

libcurl/7.62.0 OpenSSL/1.1.1a (WinSSL) zlib/1.2.11 brotli/1.0.7 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) nghttp2/1.35.0

I am using the nightly build of Harbour.

Regards,
Ash

Baxajaun

unread,
Mar 30, 2022, 9:13:59 AM3/30/22
to Harbour Users
Dear Eric,

Sorry for delay.  My script for 64 bits.
----
REM MinGW 11.2 64 bits UCRT
set PATH=%PATH%;F:\Develop\CCompilers\WinLibs\V11\64bitsUCRT\mingw64\bin;F:\TMP\Harbour\curl;F:\TMP\Harbour\curl\lib;F:\TMP\Harbour\curl\bin;F:\TMP\Harbour\curl\include;
set PATH=%PATH%;F:\TMP\Harbour\openssl;F:\TMP\Harbour\openssl3\lib;F:\TMP\Harbour\openssl3\lib\MinGW;F:\TMP\Harbour\openssl3\include\openssl3;F:\TMP\Harbour\openssl3\bin
set HB_INSTALL_PREFIX=F:\TMP\Harbour\MinGW\64bitsUCRT
set HB_PLATFORM=win
set HB_COMPILER=mingw64

set HB_STATIC_CURL=yes
set HB_STATIC_OPENSSL=yes
set HB_TIP_OPENSSL=yes
SET HB_HAS_OPENSSL=yes
SET HB_WITH_CURL=F:\TMP\Harbour\curl\include
set HB_WITH_OCILIB=F:\ocilib\Windows_Binaries\ocilib-4.7.4-windows\include  

SET HB_WITH_OPENSSL=F:\TMP\Harbour\openssl\include
REM set HB_WITH_SSH=F:\Develop\Harbour-Source\SSH\32\include
SET HB_BUILD_CONTRIB_DYN=yes
SET HB_BUILD_DYN=yes
set HB_TRACE=yes
set HB_BUILD_VERBOSE=yes
set HB_REBUILD_EXTERN=yes

win-make clean install > logMinGW11264UCRT.txt 2>&1
---

I usually download curl and openssl from https://curl.se/windows/

For MinGW version i'm using Brech Sanders compilation from winlibs.com

Kind regards,

Itamar Lins

unread,
Mar 30, 2022, 9:28:26 AM3/30/22
to Harbour Users
Hi!
How to make Harbour 32/64 Bit GCC using OpenSSL, Curl with static lib.
https://groups.google.com/g/harbour-users/c/cYtBNAT_MzY/m/VfHO0fxLAgAJ

Best regards,
Itamar M. Lins Jr.

Nenad Batocanin

unread,
Mar 30, 2022, 1:37:48 PM3/30/22
to harbou...@googlegroups.com

Hi!

 

I need somethig like this (command line):

 

curl -X POST --header "Content-Type: application/json"  --cert "c:\tmp\digcert.nochain.p12:1234567" -d "@c:\tmp\file.json" https://someurl

 

Actualy, I need to send JSON file but with digital certificate. Is this possible in Harbour version of Curl?

 

regards, Nenad

 

 

Baxajaun

unread,
Mar 30, 2022, 3:13:47 PM3/30/22
to Harbour Users
Hi Nenad,


I hope helps you.

Kind regards,

Nenad Batocanin

unread,
Mar 30, 2022, 9:53:25 PM3/30/22
to harbou...@googlegroups.com

Thanks for the link, but no one mentions the certificates (--cert directives), so I will have to solve the problem in another way ...

 

Regards, NB

--

--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Baxajaun

unread,
Mar 31, 2022, 9:45:21 AM3/31/22
to Harbour Users
Hi Nenad,

please, try with  CURLOPT_SSLCERT


I hope it helps you.

Kind regards,

Nenad Batocanin

unread,
Mar 31, 2022, 10:16:44 AM3/31/22
to harbou...@googlegroups.com

Yes, it seems to be the solution. Unfortunately, I don't have time to try now, but I'll try as soon as I can.

 

Thank you for your help!

Regards, Nenad

Maurizio la Cecilia

unread,
Apr 8, 2022, 7:14:19 AM4/8/22
to harbou...@googlegroups.com
Hi all,
this Eric message has renewed an old headache I had some year ago...

Confident of the success that the guys reported, I tried again to build the static hbcurl library using MinGW gcc contained in MSYS2.
Regarding hbssl I have no problem getting the related static libraries from the ssl files coming from MSYS2 and, as I showed Eric, the test program <hbroot> /contrib/hbssl/tests/test.prg works, like my statically linking hbssl applications.

Well, despite trying to use both the curl files from MSYS2 and from the distro kindly made available by Viktor, and following the instructions that some of you have suggested, the result was the same as a few years ago: the libraries are generated, the test executable is produced but still continues to require the presence, in the system path or in the program folder, of the dll in order to work (and it works well with the dll ...).

At this point, to remove any doubts and to compare the results, I would ask you to check if the program <hbroot> /contrib/hbcurl/tests/ftp_uldl.prg actually links statically to curl by launching its executable from an aseptic shell (just send the SET PATH = command without parameters).
If your test is successful I would ask you to specify the method followed to obtain static hbcurl and the size of the ftp_uldl.exe executable obtained.
So I hope I can understand why it doesn't work on my side.

Looking forward to your reply, TIA.
--
Maurizio
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Antonio Carlos Pantaglione

unread,
Apr 11, 2022, 6:20:39 PM4/11/22
to Harbour Users
You can try chilkat.dll, here a tool page that convert any curl string to foxpro:


Regards,

Toninho.

Nenad Batocanin

unread,
Apr 12, 2022, 9:46:37 AM4/12/22
to harbou...@googlegroups.com

Thank you very much! I know this library, but I haven't tried it. For now, I have solved the problem with my own functions.

 

Regards, NB

 

From: harbou...@googlegroups.com [mailto:harbou...@googlegroups.com] On Behalf Of Antonio Carlos Pantaglione
Sent: Tuesday, April 12, 2022 12:21 AM
To: Harbour Users <harbou...@googlegroups.com>
Subject: Re: [harbour-users] Re: curl ssl FiveTechSoft Harbour_builder

 

You can try chilkat.dll, here a tool page that convert any curl string to foxpro:

--

--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages