Static linking issue under cygwin.

Vladimir A. Petrov vaporg@gmail.com
Sat May 23 19:21:00 GMT 2009


Hello!

I've faced with strange static linking issue in Cygwin environment.
Trivial C program can not be linked against PostgreSQL libpq with the
following diagnostics:

$ gcc -Wall -I /cygdrive/c/Program\ Files/PostgreSQL/8.2/include/ -L
/cygdrive/c/Program\ Files/PostgreSQL/8.2/lib -lpq -o pgtest.exe
pgtest.c
/cygdrive/c/DOCUME~1/vap/LOCALS~1/Temp/cclXAlCk.o:pgtest.c:(.text+0x33):
undefined reference to `_PQconnectdb'
/cygdrive/c/DOCUME~1/vap/LOCALS~1/Temp/cclXAlCk.o:pgtest.c:(.text+0x78):
undefined reference to `_PQstatus'
/cygdrive/c/DOCUME~1/vap/LOCALS~1/Temp/cclXAlCk.o:pgtest.c:(.text+0x8c):
undefined reference to `_PQerrorMessage'
/cygdrive/c/DOCUME~1/vap/LOCALS~1/Temp/cclXAlCk.o:pgtest.c:(.text+0xc5):
undefined reference to `_PQfinish'
/cygdrive/c/DOCUME~1/vap/LOCALS~1/Temp/cclXAlCk.o:pgtest.c:(.text+0xd9):
undefined reference to `_PQfinish'
collect2: ld returned 1 exit status

The library is at place and has those symbols defined

$ nm /cygdrive/c/Program\ Files/PostgreSQL/8.2/lib/libpq.a | egrep
'(_PQconnectdb|_PQstatus|_PQerrorMessage|_PQfinish)'
00000000 T _PQstatus
00000000 I __imp__PQstatus
00000000 T _PQfinish
00000000 I __imp__PQfinish
00000000 T _PQerrorMessage
00000000 I __imp__PQerrorMessage
00000000 T _PQconnectdb
00000000 I __imp__PQconnectdb

This libpq.a is from PostgreSQL 8.2.9 distribution for win32.
My cygcheck.out is in the attachment.

The similar problem is also reproducible at the another PC with
different Cygwin installation and with different set of libraries
(opengl-1.1.0-10 and freeglut-2.4.0-1) that in this case are part of
the Cygwin distribution and were installed via standard Cygwin setup
program. For details see attached fly-cubes-cygcheck.out and
fly-cubes-link-failure.out. Most strange thing that belongs to this
issue is that this sources could be successfully linked with the same
package about one month ago, but after some day it became broken
without any sight cause because Cygwing installation had never been
changed.

Does anybody knows why this happens and how to solve this?

Any help will be very appreciated.
Thank you.
---
/vap/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 13375 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20090523/31810bbd/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fly-cubes-cygcheck.out
Type: application/octet-stream
Size: 20013 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20090523/31810bbd/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fly-cubes-link-failure.out
Type: application/octet-stream
Size: 20574 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20090523/31810bbd/attachment-0002.obj>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list