trying to compile program under redhat.
Results 1 to 8 of 8

Thread: trying to compile program under redhat.

  1. #1
    Member
    Join Date
    Aug 2002
    Posts
    38

    trying to compile program under redhat.

    Hiiii,

    I am trying to learn some unix programming. I have attached the code i got from my book
    "unix network programming"
    by, Richard Stevens
    A little program that request time from a server. Now for practice im suppose to change it around and play with it. But im not sure how to run it using RedHat. Under solaris it shows you how with "a.out" or something i thought
    "gcc -o daytime" would do it? and i tryed "./configure daytime" How close am i

    1> Can someone help me compile it and get it running using Redhat .

    Im just starting to try to learn programming
    I wrote it out under windows Miracle C Workbench only becasue it changes the colors for you and it is easier to see the code, well for me it is. I have attached the code.

    I know this may sound dumb and maybe obvious but i tryed to compile it under The miracle c workbench under windows just to see if it would compile and got:

    Miracle C Compiler (r3.2), written by bts.
    line 1: #include unp.h ignored--file not found.
    Compiling c:\documents and settings\administrator\desktop\notes\daytime.c
    main

    c:\documents and settings\administrator\desktop\notes\daytime.c: line 6: Parse
    Error, expecting `']'' or `NUMBER'
    'char recvline [MAXLINE + 1]'
    aborting compile

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Posts
    339
    Hi, read this thread to get some ideas on compiling a C program in Linux:
    http://www.antionline.com/showthread...hreadid=233985

    The reason you got error when compiling it in Windows is the compiler couldn't find the header file "unp.h", which I believe contains definition for MAXLINE and other things.

    Peace always,
    <jdenny>
    Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
    I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds


  3. #3
    Member
    Join Date
    Aug 2002
    Posts
    38
    Hiii

    gcc daytime.c -o daytime
    daytime.c:1:24: unp.h: No usch file or directory

  4. #4
    Senior Member
    Join Date
    Jul 2002
    Posts
    339
    As I mentioned, the error occured because the compiler (gcc this time) couldn't find the header file "unp.h".

    I'm not sure how the program works, but apparently it consists of two files, the main program "daytime.c" and header file "unp.h". daytime.c contains the main routines of the program and uses some macros, structures, etc (like MAXLINE) defined in unp.h. BOTH must exist in the same directory in order to compile successfully.

    So, find your unp.h file, put it in the same directory as daytime.c and try to recompile. HTH. Good luck.

    Peace always,
    <jdenny>
    Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
    I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds


  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    1,050
    gcc daytime.c -o daytime
    daytime.c:1:24: unp.h: No usch file or directory
    You're on the right track you just had the files the wrong way try it like this

    gcc -o <file name> <file name.c>

    try that that should compile it
    hope i helped
    By the sacred **** of the sacred psychedelic tibetan yeti ....We\'ll smoke the chinese out
    The 20th century pharoes have the slaves demanding work
    http://muaythaiscotland.com/

  6. #6
    Senior Member
    Join Date
    Jan 2002
    Posts
    187
    well for some reason i can't seem to download the file you attached, but maybe i can help with the compiler command

    gcc starts is the c compiler
    the -o modifer lets you name the object file. if you didn't use it, it would name the file a.out.

    so typing
    gcc -o <source code> <program name> will return the compiled program <program name>

    to start the program, you would type ./<program name>
    U suk at teh intuhnet1!!1!1one

  7. #7
    im trying to do the same exact thing COMPILE A C FILE. except im trying to it on windows. anyone wanna help me. i have downloaded several command based porgrams but dont understand any.

  8. #8
    Member
    Join Date
    Aug 2001
    Posts
    90
    Here we go:

    Heres something that might help. In your code, change the line to:

    #include <unp.h>

    and do as jdenny says; check if you have the unp.h header anywhere on your machine. Because that apparently is your problem.

    prodikal and Jabberwocky: Actually, both gcc -o file.c file.out AND gcc file.c -o file.out will / should work. I've used both, and they work just fine, providing the same result. Both formats are acceptable. See, the compilation DOES begin for her, it just gives an error. And yes Natasha, if you use plain old gcc file.c your object file will be a.out ( as in solaris ).

    Once you're done, doing ./objectfile.out will run the thing for you.

    Hope this helps.
    Cheers

    whoops. Mess up.
    It's gcc -o file.out file.c
    heh heh


    either / or

    gcc -o file.out file.c or gcc file.c -o file.out
    I blame you cos my mind is not my own, so don't blame me if I trespass in your zone!

Posting Permissions

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