delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/05/23/16:03:26

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4A18592F.6010107@gmail.com>
Date: Sat, 23 May 2009 21:14:39 +0100
From: Dave Korn <dave DOT korn DOT cygwin AT googlemail DOT com>
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Static linking issue under cygwin.
References: <4f8dccd00905231221v2f82acb9rcf1ffa9f228650be AT mail DOT gmail DOT com> <4A184ED3 DOT 70504 AT aol DOT com>
In-Reply-To: <4A184ED3.70504@aol.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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).


    cheers,
      DaveK

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019