Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile a C-program on UNIX

Status
Not open for further replies.

DEWELN

MIS
Nov 28, 2002
7
0
0
SG
I have to recompile a few C-programs on UNIX. I found a Makefile but it seems to be old (It refers to an old version of oracle) . The command "make" gives errors. How can I recompile the programs ?
I have now experience in C. The author of this progarm left the company.
Here is the current Makefile :
SHELL=/usr/bin/ksh

CC=cc

LINK=cc

#INCLUDEDIR=/tmp/981715/include
INCLUDEDIR=/opt/lmlogging/source/include
CFLAGS=-g -c -DCONNECTION_KEEPALIVE -I$(INCLUDEDIR)

LDFLAGS= -lc -lm

EXE=lmc00200
ORACLE_HOME=/opt/app/oracle/product/7.3.4

PROC = /opt/app/oracle/product/7.3.4/bin/proc MODE=ANSI PARSE=PARTIAL INCLUDE=$(INCLUDEDIR) INAME=

#COMDIRS = /tmp/981715/uls
#COMDIRS_OBJ = /tmp/981715/uls/*.o
COMDIRS = /opt/lmlogging/source/include
COMDIRS_OBJ = /opt/lmlogging/source/uls/*.o
ALL: $(EXE)

ORALIBS = $(ORACLE_HOME)/lib/libnlsrtl3.a $(ORACLE_HOME)/lib/libcore3.a $(ORACLE_HOME)/lib/libsqlnet.a $(ORACLE_HOME)/lib/libepc.a $(ORACLE_HOME)/lib/libncr.a $(ORACLE_HOME)/lib/libsql.a $(ORACLE_HOME)/lib/libclient.a $(ORACLE_HOME)/lib/libgeneric.a $(ORACLE_HOME)/lib/libcommon.a $(ORACLE_HOME)/lib/libc3v6.a

$(EXE).c: $(EXE).sqc
$(PROC)$(EXE).sqc

$(EXE).o: $(EXE).c
$(CC) $(CFLAGS) $(EXE).c

$(EXE): $(EXE).o
$(LINK) $(ORALIBS) $(LDFLAGS) -o $(EXE) $(EXE).o $(COMDIRS_OBJ)

Can you give me some advise ?
 
To compile a simple program you don't need a makefile.

Just use the c compiler with your unix or get gcc if
it's available and compile.

ex:
Code:
#include <stdio.h>
#include <stdlib.h>

void greet(char *, int, int);

int main(void) {

greet(&quot;Hi how are you?&quot;,5,0);
return 0;
}

void greet(char *xstr, int y, int z) {

    while (z < y) {
          printf(&quot;%s\n&quot;, xstr);
          z++;
    }
}

For gcc: gcc filename.c -o filename
./filename
Hi how are you?
Hi how are you?
Hi how are you?
Hi how are you?
Hi how are you?

HTH
 
Thanks,
I have to find out which C-compiler is installed on UNIX.
Then i shall try to compile as you suggest.
 
How can i see which compiler is installed on UNIX ? I don't find GCC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top