Skip site navigation (1) Skip section navigation (2)

Re: Compiling libpq with VisualC

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Compiling libpq with VisualC
Date: 2004-05-28 19:20:17
Message-ID: 200405281920.i4SJKH218434@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-hackers-win32pgsql-patches
I noticed that SYSCONFDIR will also be an issue for relocatable installs
just like localedir.  I will address them in the same way either as an
environment variable or libpq function call to set the location.

Your patch has been added to the PostgreSQL unapplied patches list at:

	http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Andreas Pflug wrote:
> Some modifications are needed to compile libpq with vc6:
> 
> fe-connect.c:
> - pg_config_paths.h isn't available. SYSCONFDIR is already defined so 
> fe-connect.c doesn't need to include that.
> patch appended
> 
> win32.mak:
> - pg_config.h must be generated
> - port/pgstrcasecmp.c is needed
> - port/path.c is not needed
> - the current cvs version includes some bogus cr characters, when 
> checking out with wincvs the file will contain several cr cr lf lines 
> which will confuse nmake.
> 
> Because the last problem might be difficult to handle as diff, I 
> attached win32.mak as complete file, with all cr stripped so it may be 
> committed safely with any cvs client.
> 
> Regards,
> Andreas

> Index: fe-connect.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
> retrieving revision 1.271
> diff -u -r1.271 fe-connect.c
> --- fe-connect.c	26 May 2004 18:35:51 -0000	1.271
> +++ fe-connect.c	28 May 2004 11:48:56 -0000
> @@ -29,7 +29,10 @@
>  #include "libpq-fe.h"
>  #include "libpq-int.h"
>  #include "fe-auth.h"
> +
> +#ifndef SYSCONFDIR
>  #include "pg_config_paths.h"
> +#endif
>  
>  #ifdef WIN32
>  #include "win32.h"
> 

> # Makefile for Microsoft Visual C++ 5.0 (or compat)
> 
> # Will build a Win32 static library libpq(d).lib
> #        and a Win32 dynamic library libpq(d).dll with import library libpq(d)dll.lib
> # USE_SSL=1 will compile with OpenSSL
> # DEBUG=1 compiles with debugging symbols
> 
> 
> !MESSAGE Building the Win32 static library...
> !MESSAGE
> 
> !IFDEF DEBUG
> OPT=/Od /Zi /MDd
> LOPT=/DEBUG
> DEBUGDEF=/D _DEBUG
> OUTFILENAME=libpqd
> !ELSE
> OPT=/O2 /MD
> LOPT=
> DEBUGDEF=/D NDEBUG
> OUTFILENAME=libpq
> !ENDIF
> 
> !IF "$(OS)" == "Windows_NT"
> NULL=
> !ELSE 
> NULL=nul
> !ENDIF 
> 
> CPP=cl.exe
> RSC=rc.exe
> 
> !IFDEF DEBUG
> OUTDIR=.\Debug
> INTDIR=.\Debug
> CPP_OBJS=.\Debug/
> !ELSE
> OUTDIR=.\Release
> INTDIR=.\Release
> CPP_OBJS=.\Release/
> !ENDIF
> 
> 
> ALL : config "$(OUTDIR)\$(OUTFILENAME).lib" "$(OUTDIR)\$(OUTFILENAME).dll" 
> 
> CLEAN :
> 	-(at)erase "$(INTDIR)\getaddrinfo.obj"
> 	-(at)erase "$(INTDIR)\pgstrcasecmp.obj"
> 	-(at)erase "$(INTDIR)\thread.obj"
> 	-(at)erase "$(INTDIR)\inet_aton.obj"
> 	-(at)erase "$(INTDIR)\crypt.obj"
> 	-(at)erase "$(INTDIR)\noblock.obj"
> 	-(at)erase "$(INTDIR)\dllist.obj"
> 	-(at)erase "$(INTDIR)\md5.obj"
> 	-(at)erase "$(INTDIR)\ip.obj"
> 	-(at)erase "$(INTDIR)\fe-auth.obj"
> 	-(at)erase "$(INTDIR)\fe-protocol2.obj"
> 	-(at)erase "$(INTDIR)\fe-protocol3.obj"
> 	-(at)erase "$(INTDIR)\fe-connect.obj"
> 	-(at)erase "$(INTDIR)\fe-exec.obj"
> 	-(at)erase "$(INTDIR)\fe-lobj.obj"
> 	-(at)erase "$(INTDIR)\fe-misc.obj"
> 	-(at)erase "$(INTDIR)\fe-print.obj"
> 	-(at)erase "$(INTDIR)\fe-secure.obj"
> 	-(at)erase "$(INTDIR)\pqexpbuffer.obj"
> 	-(at)erase "$(OUTDIR)\libpqdll.obj"
> 	-(at)erase "$(OUTDIR)\win32.obj"
> 	-(at)erase "$(OUTDIR)\$(OUTFILENAME).lib"
> 	-(at)erase "$(OUTDIR)\$(OUTFILENAME).dll"
> 	-(at)erase "$(OUTDIR)\libpq.res"
> 	-(at)erase "*.pch"
> 	-(at)erase "$(OUTDIR)\libpq.pch"
> 	-(at)erase "$(OUTDIR)\$(OUTFILENAME)dll.exp"
> 	-(at)erase "$(OUTDIR)\$(OUTFILENAME)dll.lib"
> 	-(at)erase "$(INTDIR)\wchar.obj"
> 	-(at)erase "$(INTDIR)\encnames.obj"
> 
> 
> 
> config: ..\..\include\pg_config.h
> 
> ..\..\include\pg_config.h: ..\..\include\pg_config.h.win32
> 	copy ..\..\include\pg_config.h.win32 ..\..\include\pg_config.h
> 
> 
> "$(OUTDIR)" :
>     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
> 
> CPP_PROJ=/nologo /W3 /GX $(OPT) /I "..\..\include" /D "FRONTEND" $(DEBUGDEF) /D\
>  "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\
>  /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c  /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP"
> 
> !IFDEF USE_SSL
> CPP_PROJ=$(CPP_PROJ) /D USE_SSL
> SSL_LIBS=ssleay32.lib libeay32.lib gdi32.lib
> !ENDIF
> 
> CPP_SBRS=.
> 
> LIB32=link.exe -lib
> LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\$(OUTFILENAME).lib" 
> LIB32_OBJS= \
> 	"$(INTDIR)\win32.obj" \
> 	"$(INTDIR)\getaddrinfo.obj" \
> 	"$(INTDIR)\pgstrcasecmp.obj" \
> 	"$(INTDIR)\thread.obj" \
> 	"$(INTDIR)\inet_aton.obj" \
>         "$(INTDIR)\crypt.obj" \
> 	"$(INTDIR)\noblock.obj" \
> 	"$(INTDIR)\dllist.obj" \
> 	"$(INTDIR)\md5.obj" \
> 	"$(INTDIR)\ip.obj" \
> 	"$(INTDIR)\fe-auth.obj" \
> 	"$(INTDIR)\fe-protocol2.obj" \
> 	"$(INTDIR)\fe-protocol3.obj" \
> 	"$(INTDIR)\fe-connect.obj" \
> 	"$(INTDIR)\fe-exec.obj" \
> 	"$(INTDIR)\fe-lobj.obj" \
> 	"$(INTDIR)\fe-misc.obj" \
> 	"$(INTDIR)\fe-print.obj" \
> 	"$(INTDIR)\fe-secure.obj" \
> 	"$(INTDIR)\pqexpbuffer.obj" \
> 	"$(INTDIR)\wchar.obj" \
> 	"$(INTDIR)\encnames.obj"
> 
> 
> RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
> 
> LINK32=link.exe
> LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib $(SSL_LIBS)  \
>  /nologo /subsystem:windows /dll $(LOPT) /incremental:no\
>  /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\$(OUTFILENAME).dll"\
>  /implib:"$(OUTDIR)\$(OUTFILENAME)dll.lib"  /def:$(OUTFILENAME)dll.def
> LINK32_OBJS= \
> 	"$(INTDIR)\libpqdll.obj" \
> 	"$(OUTDIR)\$(OUTFILENAME).lib" \
> 	"$(OUTDIR)\libpq.res"
> 
> 
> "$(OUTDIR)\$(OUTFILENAME).lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
>     $(LIB32) @<<
>   $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
> <<
> 
> "$(INTDIR)\libpq.res" : "$(INTDIR)" libpq.rc
>     $(RSC) $(RSC_PROJ) libpq.rc
> 
> 
> "$(OUTDIR)\$(OUTFILENAME).dll" : "$(OUTDIR)" "$(OUTDIR)\libpqdll.obj" "$(INTDIR)\libpqdll.obj" "$(INTDIR)\libpq.res"
>     $(LINK32) @<<
>   $(LINK32_FLAGS) $(LINK32_OBJS)
> <<
> 
> "$(INTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\port\getaddrinfo.c
> <<
> 
> "$(INTDIR)\pgstrcasecmp.obj" : ..\..\port\pgstrcasecmp.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\port\pgstrcasecmp.c
> <<
> 
> "$(INTDIR)\thread.obj" : ..\..\port\thread.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\port\thread.c
> <<
> 
> "$(INTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\port\inet_aton.c
> <<
> 
> "$(INTDIR)\crypt.obj" : ..\..\port\crypt.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\port\crypt.c
> <<
> 
> "$(INTDIR)\noblock.obj" : ..\..\port\noblock.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\port\noblock.c
> <<
> 
> "$(INTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\backend\lib\dllist.c
> <<
> 
> 
> "$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\backend\libpq\md5.c
> <<
> 
> "$(INTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
>     $(CPP) @<<
>     $(CPP_PROJ) ..\..\backend\libpq\ip.c
> <<
> 
> "$(INTDIR)\wchar.obj" : ..\..\backend\utils\mb\wchar.c
>     $(CPP) @<<
>     $(CPP_PROJ) /I "." ..\..\backend\utils\mb\wchar.c
> <<
> 
> 
> "$(INTDIR)\encnames.obj" : ..\..\backend\utils\mb\encnames.c
>     $(CPP) @<<
>     $(CPP_PROJ) /I "." ..\..\backend\utils\mb\encnames.c
> <<
> 
> 
> .c{$(CPP_OBJS)}.obj::
>    $(CPP) @<<
>    $(CPP_PROJ) $<
> <<
> 
> .cpp{$(CPP_OBJS)}.obj::
>    $(CPP) @<<
>    $(CPP_PROJ) $< 
> <<
> 
> .cxx{$(CPP_OBJS)}.obj::
>    $(CPP) @<<
>    $(CPP_PROJ) $< 
> <<
> 
> .c{$(CPP_SBRS)}.sbr::
>    $(CPP) @<<
>    $(CPP_PROJ) $< 
> <<
> 
> .cpp{$(CPP_SBRS)}.sbr::
>    $(CPP) @<<
>    $(CPP_PROJ) $< 
> <<
> 
> .cxx{$(CPP_SBRS)}.sbr::
>    $(CPP) @<<
>    $(CPP_PROJ) $< 
> <<

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2004-05-28 19:23:24
Subject: Re: yet another contrib module
Previous:From: Tom LaneDate: 2004-05-28 19:19:29
Subject: Re: SELECT * FROM <table> LIMIT 1; is really slow

pgsql-patches by date

Next:From: Andrew DunstanDate: 2004-05-28 19:31:14
Subject: Re: patch for different join result order on regression test for
Previous:From: Tom LaneDate: 2004-05-28 19:02:38
Subject: Re: Link errors on win32

pgsql-hackers-win32 by date

Next:From: Thomas SwanDate: 2004-05-28 20:48:32
Subject: could not locate my own executable path
Previous:From: Andrew DunstanDate: 2004-05-28 18:52:04
Subject: Re: Re : Win32 binaries test / pg_dump problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group