bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trouble linking cdk


From: Peter Jay Salzman
Subject: Re: trouble linking cdk
Date: Fri, 20 Jul 2001 06:55:23 -0700
User-agent: Mutt/1.3.18i

i found the answer (actually, someone had suggested this).

the object files go before the linking directives, so this doesn't work:

  gcc -o ohs `gtk-config --libs` -lcdk -lncurses callback.o (other .o files)

but this does:

  gcc -o ohs callback.o (other .o files) `gtk-config --libs` -lcdk -lncurses

note that gcc seems to already look in /usr/local/lib for static libraries,
so my -L directive was superfluous.

i don't see anything in the man pages that could've prevented me from falling
into this trap.  i guess the past few years i've been "getting it right"
without knowing that "object files come before linking directives for gcc".

the wierd thing is that gcc found the static library (i checked -- gcc does
produce a fatal error if it can't find a lib).  it just didn't DO anything
with the library when the object files are listed at the end.

otoh, cdk is nothing short of amazing.  whoever the author is, he did a
terrific job!

pete

        
begin: Thomas Dickey <address@hidden> quote
> On Thu, Jul 19, 2001 at 04:45:07PM -0700, Peter Jay Salzman wrote:
> > dear all,
> > 
> > this is driving me nuts.  i installed (make, make install) the cdk.  the
> > example programs compiled and linked fine.  i'm having trouble linking my
> > own programs that use cdk.
> > 
> >   gcc -o ohs `gtk-config --libs` -lcdk -lncurses -L/usr/local/lib callback.o
> 
> depends on the system - on some, you must put the -L/usr/local/lib
> before the -lcdk (likewise, -lcdk before -lncurses).  This is true of
> most linkers if the library is static (shared libraries are treated
> differently - the whole table of contents is usually loaded on the first
> time the file is opened).
> 
> >   main.o content.o pfunctions.o GTKmain.o NCURSESmain.o
> >   NCURSESmain.o: In function `NCURSESmain':
> >   NCURSESmain.o(.text+0x37): undefined reference to `initCDKScreen'
> >   NCURSESmain.o(.text+0x44): undefined reference to `initCDKColor'
> >   NCURSESmain.o(.text+0x118): undefined reference to `newCDKLabel'
> >   NCURSESmain.o(.text+0x147): undefined reference to `newCDKMenu'
> >   (snip)
> > 
> > 
> > the compiler /should/ complain if it doesn't find the libcdk.a, so i assume
> > it's finding this file.
> 
> not all linkers do (I don't recall which offhand).
>  
> > however, i assume that all the *CDK* functions are in libcdk.a.  can some
> > kind soul guess why i'm getting all these undefined references?
> > 
> > i realize this is a gcc question, not ncurses.  but i'm really stumped!  if 
> > i
> > take NCURSESmain.c, give it a main() and compile it by itself, it works:
> > 
> > address@hidden gcc -c blah.c -I/usr/local/include/cdk
> > address@hidden gcc blah.o -lncurses -lcdk
> > 
> > but it seems to choke when i link it with the other functions.
> > 
> > help?
> > 
> > thanks!
> > pete
> > 
> > -- 
> > "The following addresses had permanent fatal errors..."      address@hidden
> >                                -- Mailer Daemon              www.dirac.org/p
> > 
> > _______________________________________________
> > Bug-ncurses mailing list
> > address@hidden
> > http://mail.gnu.org/mailman/listinfo/bug-ncurses
> 
> -- 
> Thomas E. Dickey <address@hidden>
> http://dickey.his.com
> ftp://dickey.his.com

-- 
"The following addresses had permanent fatal errors..."      address@hidden
                               -- Mailer Daemon              www.dirac.org/p



reply via email to

[Prev in Thread] Current Thread [Next in Thread]