Compiling a C program on Linux

Posted on 2005-04-27
Last Modified: 2010-04-02

I found a simple C program that does some stats I need.  I am runinng RedHat Linux v3, with a gcc compiler.  But I've never compiled anything.  Well I've done some make's, but no pure compiles.  What would be the command to compile this into a binary?


#include <stdio.h>
#include <time.h>
#include <syslog.h>

#define BUFFER_SIZE 8192

void main(void) {

char buf[BUFFER_SIZE];
long count, bytes;
time_t lastupdate;

lastupdate = time(NULL);
while (fgets(buf, BUFFER_SIZE, stdin)) {
   bytes += (strlen(buf) - 1);
   if (time(NULL) > (lastupdate + REPORT_INTERVAL)) {
      openlog("", LOG_NDELAY, LOG_LOCAL3);
      syslog(LOG_INFO, "Syslog-ng\\Lines=%d Syslog-ng\\Bytes=%d", count, bytes);
      lastupdate += REPORT_INTERVAL;
      count = 0;
      bytes = 0;

Question by:shanepresley
    LVL 45

    Accepted Solution

    cd /path/to/syslog-perf.c

    cc syslog-perf.c

    this will create an executable called a.out in the same directory ... To create an executable with different name, use -o option

    cc -o sperf syslog-perf.c
    LVL 1

    Author Comment

    Thanks!!  I have a couple other questions about this script, but I'll open a new question.  


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Microsoft vcsetup.exe and vcssetup.exe 8 380
    Which checksum is this? 7 132
    Problem to show menu 5 72
    Arduino EDI - Programming language 3 31
    This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now