delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/10/24/12:51:49

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
From: "Jeff Lu" <jklcom AT mindspring DOT com>
To: "Charles S. Wilson" <cwilson AT ece DOT gatech DOT edu>
Cc: <cygwin AT sourceware DOT cygnus DOT com>
Subject: RE: Question
Date: Tue, 24 Oct 2000 12:43:10 -0400
Message-ID: <NDBBIHPECLIGKCCLMACAOEHLCHAA.jklcom@mindspring.com>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
In-reply-to: <39F5B820.41EBF387@ece.gatech.edu>
Importance: Normal

Thanks Chuck,

I want to link with dll but couldn't get it to work

I was able to compile and link with the static lib
# compile
gcc -o getdata.o -c getdata.c -DGDBM_STATIC
gcc -o utils.o   -c utils.c   -DGDBM_STATIC

#link
gcc -static -o /home/jeff/getdata.cgi getdata.o utils.o -lgdbm

but not with this long command
gcc -static -o /home/jeff/getdata.cgi getdata.c -lgdbm utils.c -DGDBM_STATIC


-----Original Message-----
From: Charles S. Wilson [mailto:cwilson AT ece DOT gatech DOT edu]
Sent: Tuesday, October 24, 2000 12:26 PM
To: Jeff Lu
Cc: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: Question




Jeff Lu wrote:
>
> I compiled it with CFLAGS=-DGDBM_STATIC such as this
> gcc -o /home/jeff/getdata.cgi getdata.c -lgdbm utils.c -DGDBM_STATIC
>
> This takes care of the rename problem but am still getting dbm_open,
> dbm_fetch etc. as undefined reference
>
> I've even tried to explicitly link it to /usr/lib/libgdbm.a but that
didn't
> help
>

Okay, so it appears that you want to link statically and not use the
dll, right?  You can do this because the gdbm package provides *both* a
static lib *AND* a dll+import library.

If you want to link statically, then you need to add "-static" to your
link command.  Now, since you are going straight from .c files to an
executable all in one step, your compile command and your link command
are the same.  So, do this:

gcc -static -o /home/jeff/getdata.cgi getdata.c -lgdbm utils.c
-DGDBM_STATIC

You could also do this:

# compile
gcc -o getdata.o -c getdata.c -DGDBM_STATIC
gcc -o utils.o   -c utils.c   -DGDBM_STATIC

#link
gcc -static -o /home/jeff/getdata.cgi getdata.o utils.o -lgdbm

but not with this long command
gcc -static -o /home/jeff/getdata.cgi getdata.c -lgdbm utils.c -DGDBM_STATIC



--Chuck


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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