Problem with Stevens book: Advanced Programming in the UNIX Environment

Problem with Stevens book: Advanced Programming in the UNIX Environment

Post by Benjamin Janso » Sat, 17 Jun 2000 04:00:00



Hi,
well I thought someone might have read this book and can help me with
the following programming problem:
When I use the error function that is defined in the ourhdr.h file I get
an error message:
In function main:
undefined reference to 'err_quit'

But it is actually in the header file and the program is able to use it.
Could it be, that this problem occurs because I am running Linux?
Thanks for your help
Benjamin

 
 
 

Problem with Stevens book: Advanced Programming in the UNIX Environment

Post by VS » Sat, 17 Jun 2000 04:00:00


The functions err_quit etc are not library functions. They are functions
written by the author. So you have to include them in your code. They will
be in the same book.
VS

> Hi,
> well I thought someone might have read this book and can help me with
> the following programming problem:
> When I use the error function that is defined in the ourhdr.h file I get
> an error message:
> In function main:
> undefined reference to 'err_quit'

> But it is actually in the header file and the program is able to use it.
> Could it be, that this problem occurs because I am running Linux?
> Thanks for your help
> Benjamin


 
 
 

Problem with Stevens book: Advanced Programming in the UNIX Environment

Post by Benjamin Janso » Sun, 18 Jun 2000 04:00:00




> + Hi,
> + well I thought someone might have read this book

> Oh man, who /hasn't/ read that book?  The APUE is great.  (May Stevens
> rest in peace.)

> + and can help me with
> + the following programming problem:
> + When I use the error function that is defined in the ourhdr.h file I get
> + an error message:
> + In function main:
> + undefined reference to 'err_quit'
> +
> + But it is actually in the header file and the program is able to use it.
> + Could it be, that this problem occurs because I am running Linux?

> Linux is a Unix.  Linux has naught to do with it.

> The problem (methinks) is that the ourhdr.h file /declares/ err_quit but
> does not /define/ it.  There is a difference.  Take a look at err_quit in
> the header file; if it starts off with "extern" then it's probably just
> a declaration, not a definition.  (This is a fairly common mistake for
> beginning programmers.  You should read the comp.unix.programming FAQ.)

> You need to find where err_quit is actually defined, and make certain
> you're linking that in as well.

> I'd say more, but 1) I don't have the APUE with me and I'm just going on what
> you've written here, and 2) discovering it yourself will teach you more.  :-)

> Luck++;
> Phil

Sure you are right discovering it myself would teach me more. But for
that I have to discover it at all!
I also tried the sources that Richard Stevens published on his
Webserver. And when I use exclusivly his files it still doesn't work. So
I don't erally know where to search for a solution.
Benjamin
 
 
 

Problem with Stevens book: Advanced Programming in the UNIX Environment

Post by Christoph R » Mon, 19 Jun 2000 04:00:00




> > + When I use the error function that is defined in the ourhdr.h file I get
> > + an error message:
> > + In function main:
> > + undefined reference to 'err_quit'
> > I'd say more, but 1) I don't have the APUE with me and I'm just going on what
> > you've written here, and 2) discovering it yourself will teach you more.  :-)

> > Luck++;
> > Phil

> Sure you are right discovering it myself would teach me more. But for
> that I have to discover it at all!
> I also tried the sources that Richard Stevens published on his
> Webserver. And when I use exclusivly his files it still doesn't work. So
> I don't erally know where to search for a solution.
> Benjamin

Hi!
Have you ever tried to look in the index ?

    err_quit function 6, 682
    definition of, 683

I needed about 30 seconds to find it...

mfg

Christoph

 
 
 

Problem with Stevens book: Advanced Programming in the UNIX Environment

Post by Oleg Goldshmid » Sun, 25 Jun 2000 04:00:00



Quote:> well I thought someone might have read this book

Quite a few of us, I suppose. Welcome to the club. ;-)

Quote:> In function main:
> undefined reference to 'err_quit'

> But it is actually in the header file and the program is able to use
> it.

Including a header does not mean your program can use the function.
It only means your program will compile. It won't link though - for
that you need to link the actual definition (as opposed to
declaration) of the function. Get the code for err_quit() [IIRC, it is
available on the net], or type it in yourself, and link it in.  Check
your compiler/linker documentation to see how to do it. On Linux with
gcc the easiest way is, assuming the function definition is in
ourerr.c, and your program is in prog.c, and all that + ourhdr.h is in
the current directory:

$ gcc prog.c ourerr.c

Quote:> Could it be, that this problem occurs because I am running Linux?

Nothing to do with Linux. It's not an OS question at all, it's C.

--

"... We work but wit, and not by witchcraft;
 And wit depends on dilatory time." [Shakespeare]

 
 
 

Problem with Stevens book: Advanced Programming in the UNIX Environment

Post by Benjamin Janso » Mon, 26 Jun 2000 04:00:00


Actually that solved my problem. I thought this function is already
defined. Thanks a lot.
Benjamin


> > well I thought someone might have read this book

> Quite a few of us, I suppose. Welcome to the club. ;-)

> > In function main:
> > undefined reference to 'err_quit'

> > But it is actually in the header file and the program is able to use
> > it.

> Including a header does not mean your program can use the function.
> It only means your program will compile. It won't link though - for
> that you need to link the actual definition (as opposed to
> declaration) of the function. Get the code for err_quit() [IIRC, it is
> available on the net], or type it in yourself, and link it in.  Check
> your compiler/linker documentation to see how to do it. On Linux with
> gcc the easiest way is, assuming the function definition is in
> ourerr.c, and your program is in prog.c, and all that + ourhdr.h is in
> the current directory:

> $ gcc prog.c ourerr.c

> > Could it be, that this problem occurs because I am running Linux?

> Nothing to do with Linux. It's not an OS question at all, it's C.

> --

> "... We work but wit, and not by witchcraft;
>  And wit depends on dilatory time." [Shakespeare]

 
 
 

1. Advice/comments needed for revision of Stevens' "Advanced Programming in the Unix Environment"

Hello,

I work for Addison-Wesley Professional, a division of Pearson
Education in Boston. We published Rich Stevens' "Advanced Programming
in the Unix Environment" and now we're looking for revisors.  If you
are interested, or if you can recommend someone whose possesses
stellar expertise and a willingness to write, please let me know.

Also, general feedback is very helpful. What (in your opinion) needs
to be added or changed to the book?  Were there points that could use
further elaboration?  Were there unnecessary sections that could be
replaced with more useful material?

Thanks very much,

Susannah H.Buzard

2. Req help with NIC in a Fujitsu laptop

3. need help on Stevens, W Richard "advance programming in the UNIX Environment.

4. VFS: Errors

5. compiling examples from stevens 'advanced programming in unix' book.

6. Simple Linux-Win98 networking made - I can probably help you if you are interested

7. Examples from Stevens' book "Advanced Programming..."

8. Can more fonts be made available to konsole?

9. Stevens : Advanced Unix Programming

10. WANTED: Advanced Programming in Unix Env. by Stevens

11. Need good books on Advanced UNIX programming, Standard Unix C APIs

12. pick script in The UNIX Programming Environment (The UNIX Programming Environment )

13. Stevens' book : UNIX network programming