This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static linking issue under cygwin.

Tim Prince wrote:
> Vladimir A. Petrov wrote:
>> 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'
> Not strange, when gnu ld depends on order of libraries for static linking.

  But strange to anyone who's expecting Cygwin to resemble Linux in this
matter; Linux has the advantage of fully-dynamic linking at runtime, so the
symbols still appear undefined to the Linux version of 'ld', but it doesn't
complain because it expects a .SO will fill in the missing references when the
executable is running.  On Windows, executables have to be explicitly linked
against the DLL from which the symbol will be resolved, at link-time.

>  ld doesn't rescan libraries when new references are added after the scan.
>  It's strange enough to attempt to link libraries installed under "Program
> Files"

  Well, if that's where PostgreSQL installs, that's where it installs; this
maybe a win32 version for all we know.  Linking against MSVC .lib files should
work, but there could conceivably be clashes caused by the PgSQL dll bringing
the MSVC runtime into the equation (if indeed it does).


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]