This is the mail archive of the
mailing list for the Cygwin project.
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
>> 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
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: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html