Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Compiling a C program on Linux

Hello,

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?

Thanks
Shane

https://lists.balabit.hu/pipermail/syslog-ng/2004-November/006714.html

<syslog-perf.c>
#include <stdio.h>
#include <time.h>
#include <syslog.h>

#define BUFFER_SIZE 8192
#define REPORT_INTERVAL 60

void main(void) {

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

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

}
</syslog-perf.c>
0
shanepresley
Asked:
shanepresley
1 Solution
 
sunnycoderCommented:
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
0
 
shanepresleyAuthor Commented:
Thanks!!  I have a couple other questions about this script, but I'll open a new question.  

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now