Thread: Trouble Compiling Postgres 7.0.2 under Windows

Trouble Compiling Postgres 7.0.2 under Windows

From
Date:
Hi,

Would anyone be able to provide some assistance in why I'm getting these
errors when trying to compile PostgreSQL under Windows (NT/2000) using
Cygwin.

Version info:  postgresql_7.0.2
          cygwin v1.0 (latest non-beta version from Redhat/Cygnus)
          cygwin32_ipc_1.03

IPC seems to work fine - I'm putting all the files in the right place (I
think), and ./configure runs without any errors.
When I come to make the binaries, I get the following errors, and make
terminates:

<snip>
make -C ../utils dllinit.o
make[2]: Entering directory `/postgresql-7.0.2/src/utils'
gcc -I../include -I../backend   -I/usr/local/include -O2
-I/usr/local/include -Wall -Wmissing-prototypes -Wmissing-declarations   -c
-o dllinit.o dllinit.c
dllinit.c:49: conflicting types for `DllMain'
dllinit.c:44: previous declaration of `DllMain'
dllinit.c:49: conflicting types for `_cygwin_dll_entry'
dllinit.c:49: previous declaration of `_cygwin_dll_entry'
dllinit.c:81: conflicting types for `DllMain'
dllinit.c:49: previous declaration of `DllMain'
make[2]: *** [dllinit.o] Error 1
make[2]: Leaving directory `/postgresql-7.0.2/src/utils'
make[1]: *** [../utils/dllinit.o] Error 2
make[1]: Leaving directory `/postgresql-7.0.2/src/backend'
make: *** [all] Error 2

I've bodged the dllinit.c file (which I'm sure isn't the right thing to do)
enough to skip the redfinition error, but then I get a link error:

<snip>
gcc -g -o postgres.exe -Wl,--base-file,postgres.base postgres.exp
access/SUBSYS.o bootstrap/SUBSYS.o catalog/SUBSYS.o commands/SUBSYS.o
executor/SUBSYS.o lib/SUBSYS.o libpq/SUBSYS.o main/SUBSYS.o parser/SUBSYS.o
nodes/SUBSYS.o optimizer/SUBSYS.o port/SUBSYS.o postmaster/SUBSYS.o
regex/SUBSYS.o rewrite/SUBSYS.o storage/SUBSYS.o tcop/SUBSYS.o
utils/SUBSYS.o ../utils/version.o -L/usr/local/lib -lcygipc -lcrypt
-lcygwin -lkernel32
make[1]: Leaving directory `/postgresql-7.0.2/src/backend'
utils/SUBSYS.o(.text+0x42ec7):elog.c: undefined reference to `_sys_nerr'
utils/SUBSYS.o(.text+0x438a5):exc.c: undefined reference to `_sys_nerr'
collect2: ld returned 1 exit status
make[1]: *** [postgres] Error 1
make: *** [all] Error 2

I can't find any reference to sys_nerr in the source so I'm a bit stumped
how PostgreSQL would compile?
Any pointers would be greatfully received.

Thanks,
Ol

P.S. Before anyone asks, I have followed the HOWTO/portNT instructions
which did get PostgreSQL to compile, but no further.  They seem rather
convoluted (presumably because they're based upon the old Cygwin B20), and
are not very clear.  Once I've got this working I'll write up the whole
procedure and stick it on the web - with appropriate 'thankyou's etc. of
course.



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

SCEE
**********************************************************************

Re: Trouble Compiling Postgres 7.0.2 under Windows

From
Tom Lane
Date:
<Oliver_Hall@scee.net> writes:
> utils/SUBSYS.o(.text+0x42ec7):elog.c: undefined reference to `_sys_nerr'
> utils/SUBSYS.o(.text+0x438a5):exc.c: undefined reference to `_sys_nerr'
> collect2: ld returned 1 exit status
> make[1]: *** [postgres] Error 1

> I can't find any reference to sys_nerr in the source so I'm a bit stumped
> how PostgreSQL would compile?

src/include/port/win.h contains

#include <cygwin/version.h>
#if (CYGWIN_VERSION_API_MAJOR >= 0) && (CYGWIN_VERSION_API_MINOR >= 8)
#define sys_nerr _sys_nerr
#endif

which looks a tad fragile.  This is referenced as "extern int sys_nerr"
in src/backend/utils/error/elog.c and src/backend/utils/error/exc.c.

            regards, tom lane