Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Linking libraries into C programs

Re: Linking libraries into C programs

From: Steve Holdoway and Julie Holdstock <essnjay_at_kabelfoon.nl>
Date: Thu, 23 Jul 1998 22:01:37 GMT
Message-ID: <35beb038.16614944@news.caiw.nl>


On Wed, 22 Jul 1998 18:22:21 GMT, sysdev_at_adpsystems.mb.ca wrote:

>Hello all,
>
>We are using:
>
>AIX 4.1
>Oracle 7.2.3
>Pro-C 2.1.3
>- The Oracle ProC precompiler, and oraxlc compiler.
>
>We have been stuck with the problem of maintaining
>some programs that have been written for us, and
>not documented. These programs use a library
>(call it), libdir/lib.a. I am currently trying to
>figure it all out.

it's simple, donm't worry.
>
>I have so far managed to modify the makefile so
>that it can INCLUDE (or -I) a search path to other
>subdirectories. So, the #include header.h program
>statements work just fine. But, these only give me
>the global variables.
>
>
>The questions are:
>- how do we use library functions in a C program?
As if they were local. Define the stubs if you're on ansi.
>- how do we compile the program, to link these
>libraries into the program? Or, in other words,
>how do you modify the makefile to link in the
>libdir/lib.a file?

add it to the $LIBS line at the top of your make file ( as in ld -l $(LIBS) ( ? only have linux here to check against)
>
>We don't want to modify the library at all (at this
>point anyway). We just want to link it into some
>existing and new programs.

Well, you're not linking it as a shared one, so there's really no problem at all.
>
>Does anyone have an example of simple library with
>a function that would just display to screen,
>"Hello world"?
>
>
>Regards,
>
>Rodger

Rodger,

What you're trying to do is not difficult or out of the ordinary ( well, at least for an ancient old git like me ) look through the man pager on ld, and any Makefiles that you may have as templates. What you'll find is that most of them are far more complex than they ever need to be.

You'd be better off spending your next fag break ( real or retailatory ) reading about the dependencies in a make file than worrying about linking in the correct libraries to link to. The original code was written by people trying to make your life easier, honest!

Cheers,

Steve
>
>
>P.S.
>
>My ISP is really bad with the newsgroups. They put
>postings on late, and delete them early. Emails to
>sysdev_at_adpsystems.mb.ca are greatly appreciated.
>
>
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Received on Thu Jul 23 1998 - 17:01:37 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US