CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Posts
    2

    apress books source code won't compile

    I have this book, "The Definitive guide to Linux Network Programming" and the source code won't compile. I check it over to make sure there's not typo's but I still get errors. Maybe I'm not compiling them right? But I'm not the only one who gets errors. The only thing is that I might be using a different version of gcc? The code can be found HERE

    I'm curious if anyone knows if there has been a solution to this, as I haven't got anything back from their support nor does google know. The only thing I can think of is troubleshooting every piece of code in the book, and when you're just learning, that's not really something I want to do.

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: apress books source code won't compile

    Maybe book is old (new? I'm not really a linux guy). Compilation of 32270201.c using gcc 4.1 gave (no flags, just gcc 32270201.c)
    Code:
    32270201.c: In function 'main':
    32270201.c:18: warning: incompatible implicit declaration of built-in function 'exit'
    32270201.c:27: warning: incompatible implicit declaration of built-in function 'exit'
    32270201.c:39: warning: incompatible implicit declaration of built-in function 'bzero'
    32270201.c:53: warning: incompatible implicit declaration of built-in function 'exit'
    32270201.c:62: warning: incompatible implicit declaration of built-in function 'exit'
    32270201.c:81: warning: incompatible implicit declaration of built-in function 'exit'
    32270201.c:87: warning: incompatible implicit declaration of built-in function 'strlen'
    so if I get the same result as you get it's really "only" warnings.

    Grep-ing shows that exit is declared in stdlib.h, bzero & strlen are declared in string.h so add includes for those files.

    Hopefully this takes you a bit forward. If you encounter any similar issues "just" grep for the missing declaration. On a Debian system that is (example):
    grep -w exit /usr/include/*.h
    Last edited by S_M_A; August 5th, 2008 at 01:31 AM.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Aug 2008
    Posts
    2

    Re: apress books source code won't compile

    Quote Originally Posted by S_M_A
    Hopefully this takes you a bit forward. If you encounter any similar issues "just" grep for the missing declaration. On a Debian system that is (example):
    grep -w exit /usr/include/*.h
    Yea, thanks! That did the trick.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured