build Import LIB from LibPQ.DLL

build Import LIB from LibPQ.DLL

Postby Jimmy » Fri Jun 16, 2023 3:32 pm

hi,

i want to use PostgreSQL and build a "new" LIB for "latest" Version v14

i have done it for HMG / MinGW using Source of TPQSERVER but how with BCC / MSVC :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: build Import LIB from LibPQ.DLL

Postby nageswaragunupudi » Fri Jun 16, 2023 8:06 pm

May not be the latest versions, but these libs and dll might work as well
Code: Select all  Expand view
fwh\lib\hppgsql.lib
fwh\lib\libpq.lib
and
fwh\samples\libpq.dll


Also please see fwh\samples\buildh.bat to see the usage.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10642
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: build Import LIB from LibPQ.DLL

Postby Jimmy » Fri Jun 16, 2023 10:42 pm

hi,

thx for Answer.

File c:\fwh64\samples\libpq.dll are Version v9.6.3 and 32 Bit (!) and there is no fwh64\lib\libpq.lib

for HMG i have build a Lib "a" (MinGW) for LibPQ.DLL 64 Bit ... but i don´t remember how ...

---

hm ... CLASS TPQSERVER have some Source

Code: Select all  Expand view
c:\hmg.3.4.4\1\hbpgsql\postgres.c
c:\hmg.3.4.4\1\hbpgsql\rddcopy.c
c:\hmg.3.4.4\1\hbpgsql\postgres.ch
c:\hmg.3.4.4\1\hbpgsql\hbpgsql.h
c:\hmg.3.4.4\1\hbpgsql\libpq-fe.h
c:\hmg.3.4.4\1\hbpgsql\tpostgre.prg


c:\hmg.3.4.4\1\hbpgsql\hbpgsql.hbc
Code: Select all  Expand view
description=PostgreSQL wrapper (SQL)

incpaths=.

headers=postgres.ch

libs=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF}

{unix}libs=pq
{!unix}libs=libpq
{darwin}libpaths=d:\PG\9.5\lib


c:\hmg.3.4.4\1\hbpgsql\hbpgsql.hbp
Code: Select all  Expand view
-hblib
-inc

-o${hb_name}

-w3 -es2

-depkeyhead=hbpgsql:libpq-fe.h
-depcontrol=hbpgsql:no{HB_BUILD_3RDEXT='no'}
-depcontrol=hbpgsql:${HB_WITH_PGSQL}
-depincpath=hbpgsql:d:\PG\9.5\include
-depimplibs=hbpgsql:d:\PG\9.5\lib\libpq.dll

-iflag={mingw64}-a

${hb_name}.hbx

postgres.c
rddcopy.c
tpostgre.prg


this was my *.BAT
Code: Select all  Expand view
rem this is LIBPQ.LIB from PostgreSQL
hbmk2.exe postgres.c rddcopy.c tpostgre.c -Id:\PG\9.5\include -Lc:\hmg.3.4.4\LIB-64 -llibpq-64

c:\hmg.3.4.4\1\hbpgsql\build.log
hbmk2: Dependency 'hbpgsql' found: d:\PG\9.5\include
hbmk2: Found COFF .lib with the same name, falling back to using it instead of
the .dll.
hbmk2: Created import library: liblibpq.a <= d:\PG\9.5\lib\libpq.dll
hbmk2: Creating static library... libhbpgsql.a

what do i need to change for BCC / MSVC to use with Fivewin 64 Bit :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: build Import LIB from LibPQ.DLL

Postby Antonio Linares » Sat Jun 17, 2023 9:15 am

Dear Jimmy,

You can use implib.exe to easily create them for both Borland and MSVC, 32 and 64 bits
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: build Import LIB from LibPQ.DLL

Postby Jimmy » Mon Jun 19, 2023 9:19 pm

hi Antonio,

how is the Syntax :?:

x:\>C:\BCC7\bin\implib.exe libpq.dl
Embarcadero Implib Version 3.3.0 Copyright (c) 1991-2014 Embarcadero Technologies, Inc.

Syntax: IMPLIB [options] libname[.lib] [@respfile | srcname] [srcname ...]
Options:
-a Add '_' alias for MS flavor cdecl functions
-aa Force the alias even if the function already starts with '_'
-c Case sensitive symbols
-f Force imports by name (with hints)
-s Don't convert stdcall names from Microsoft mangling
-w No Warnings

! Note : i have LibPQ.DLL (32/64 Bit) and want to build a "Import" LIB to use it with Fivewin
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: build Import LIB from LibPQ.DLL

Postby Antonio Linares » Tue Jun 20, 2023 7:30 am

Dear Jimmy,

For msvc:
implib.exe LibPQ.lib LibPQ.DLL

For bcc:
implib.exe -a LibPQ.lib LibPQ.DLL

Please notice that msvc does not provide implib.exe, as it is a Borland tool. For msvc you have to use:
dumpbin.exe /exports LibPQ.dll > LibPQ.def
lib.exe /def:LibPQ.def /OUT:LibPQ.lib

If you are using Harbour's hbmk2.exe please remember that it provides a way to automatically create the import libraries:
-depimplibs=dependency:LibPQ.dll

Not sure how the dependency is defined
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: build Import LIB from LibPQ.DLL

Postby nageswaragunupudi » Tue Jun 20, 2023 8:15 am

FWH comes bundled with
Code: Select all  Expand view
fwh\lib\libpq.lib  // 32-bit implib
fwh\lib\hbpgsql.lib // harbour postegre lib
fwh\dll\postgre\libpq.dll  // from Postgre
// this dll is also in
fwh\samples\libpq.dll


In addition you also need all the dlls in
fwh\dll\postgre\*.dll
all these dlls are also available in fwh\samples folder.

fwh\samples\buildh.bat includes the link script for these libs.

In other words,. a new user to FWH can effortlessly build a postgre application, without downloading anything and building any implibs on his own just by
Code: Select all  Expand view
buildh mypostgreapp

if he wants to build a working postre 32-bit application using (x)Harbour and bcc.

Once done, then we can go to 64bits in the next step.
For this you need to download and use all 64-bit dlls, build 64bit implib and also build Harbour's hbpgsql.lib in 64 bits.

Quick start can be made just using what FWH offers and just using buildh.bat in practically no time.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10642
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: build Import LIB from LibPQ.DLL

Postby nageswaragunupudi » Tue Jun 20, 2023 8:17 am

If any users are now working with 32-bit dlls and libs we already provided with fwh now. in the next version we will endeavor to upgrade 32-bit versions to the latest and also provide 64-bit libs and dlls.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10642
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: build Import LIB from LibPQ.DLL

Postby Jimmy » Tue Jun 20, 2023 6:15 pm

hi,

i already have a HMG App using LibPQ.DLL 64 bit Version
but "Import" LIB was build using MinGW and hbmk2

---

as i remember last 32 Bit Version of PostgreSQL "Server" was v9.x
LibPQ.DLL of Version 10 and later are all 64 Bit

to get LibPQ.DLL as 32 Bit you need to download PgAdmin which are still available as 32 Bit
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: build Import LIB from LibPQ.DLL

Postby Antonio Linares » Tue Jun 20, 2023 9:28 pm

> Not sure how the dependency is defined

ok, I found how to define it:

-depkeyhead=test:libmariadb64.dll
-depcontrol=test:yes
-depimplibs=test:libmariadb64.dll
-depincpath=test:.

hbmk2: Dependency 'test' found: .
Creating library libmariadb64.lib and object libmariadb64.exp
hbmk2: Created import library: libmariadb64.lib <= libmariadb64.dll
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: build Import LIB from LibPQ.DLL

Postby Jimmy » Thu Jun 29, 2023 9:03 am

hi,

it seems i made a Mistake to use *.HBC while using *,MAK (BCC) or *.HBP (MSVC)

under HMG I was used to work with *.HBC, where I had Libs=
but when i use BCC and *.MAK it "seems" not to work :?

after include in *.MAK
Code: Select all  Expand view
       echo c:\fwh\lib\hbpgsql.lib + >> b32.bc
       echo c:\fwh\lib\libpq.lib + >> b32.bc

32 Bit App using BCC work now :)

---

libpq.lib"seem" me the "Original" by PostgreSQL 32 / 64 Bit so my Question was wrong

i need to build a 64 Bit Version of hbpgsql.lib for Fivewin using these Files:
tpostgre.prg
postgres.c
rddcopy.c

i know to use buildh.bat ti build EXE but how to build 64 Bit LIB for MSVC :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: build Import LIB from LibPQ.DLL

Postby Antonio Linares » Thu Jun 29, 2023 9:56 am

Dear Jimmy,

Use hbmk2.exe and -hblib in the hbp file, and the files names
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: build Import LIB from LibPQ.DLL

Postby Jimmy » Fri Jun 30, 2023 5:55 am

hi Antonio,
Antonio Linares wrote:Use hbmk2.exe and -hblib in the hbp file, and the files names

YES, that seems to work :D

it compile/link now without Problem, under 64 Bit using MSVC, and i got to 1st Step to show "Catalog"

---

to build hbpgsql.LIB your need LibPQ.LIB from PostgreSQL Server and also some *.h
copy LibPQ.LIB into c:\fwh64\lib\

hbpgsql.hbP
Code: Select all  Expand view
-hblib    
-Ic:\fwh64\include
tpostgre.prg
postgres.c
rddcopy.c
-Lc:\fwh64\lib
-lFiveH64
-lFiveHC64
-lgdiplus
-lole32
-lOleDlg
-lversion
xhb.hbc
hbct.hbc
hbwin.hbc
-ldflag=/NODEFAULTLIB:msvcrt
Tpostgre.rc


hbpgsql.hbc
Code: Select all  Expand view
description=PostgreSQL wrapper (SQL)
incpaths=.
headers=postgres.ch
libs=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF}
{unix}libs=pq
{!unix}libs=libpq


MakeFWLIB.BAT
Code: Select all  Expand view
call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
c:\harbour64\bin\win\msvc64\hbmk2 hbpgsql.hbp -comp=msvc64
REN tpostgre.LIB hbpgsql.LIB  

last line ist to "rename" LIB ... how to chagene "output" Lib Name :?:
copy hbpgsql.LIB into c:\fwh64\lib\

i will make a Sample how to use CLASS TPQServer
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: build Import LIB from LibPQ.DLL

Postby nageswaragunupudi » Fri Jun 30, 2023 12:40 pm

We already have programs to use PostGre in our samples which use some extensions created by FWH already
Is there any further need to create new classes except for academic interest?
Right now we can work with PostGre server.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10642
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: build Import LIB from LibPQ.DLL

Postby Jimmy » Fri Jun 30, 2023 8:32 pm

hi,

yes ,,, but only using (old v9) 32 Bit LibPQ.DLL Interface

i want to use 64 Bit App so i need 64 Bit LibPQ.DLL / LibPQ.LIB
it would be nice if Fivewin 64 Bit Version include "external" 64 Bit LIBs like in 32 bit Version
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 52 guests