makefile

i need help with my makefile. This is my first time dealing with one.I have ,ll.C and main.C, and one header file called ll.h
main.C has the header file ll.h included and some other libraries
ll.C has the header file also.
and when i compile it i get this error:
1
2
3
4
5
6
g++		 -c -g -Wall	 ll.C
g++		 -g -Wall	 -o mylink		 ll.o -L.		 -lm		
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [mylink] Error 1


and this is my makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
###################################                                                                                                                    
#                                                                                                                                                      
###################################                                                                                                                    
CC = g++                                                                                             
CFLAGS = -g -Wall                                                       
LIB = -lm                                                                                                                          
LDFLAGS = -L.                                                                                                                         
PROG = mylink                                                                                                       
OBJ = main.o                            
OBJ = ll.o
SRC = main.C
SRC = ll.C
all : $(PROG)

$(PROG): $(OBJ)
        $(CC) -c $(CFLAGS) $(SRC)
        $(CC) $(CFLAGS) -o $(PROG) $(OBJ) $(LDFLAGS) $(LIB)


# cleanup                                                                                                                                              
clean:
        /bin/rm -f *.o $(PROG)


any help on how to fix this? and i do have a main function on main.C.
Try this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
###################################                                                                                                                    
#                                                                                                                                                      
###################################                                                                                                                    
CC = g++                                                                                             
CFLAGS = -g -Wall                                                       
LIB = -lm                                                                                                                          
LDFLAGS = -L.                                                                                                                         
PROG = mylink                                                                                                       
OBJ = main.o ll.o                            
SRC = main.C ll.C
all : $(PROG)

$(PROG): $(OBJ)
        $(CC) -c $(CFLAGS) $(SRC)
        $(CC) $(CFLAGS) -o $(PROG) $(OBJ) $(LDFLAGS) $(LIB)


# cleanup                                                                                                                                              
clean:
        /bin/rm -f *.o $(PROG)


it looks like it is only processing one of your programs (ll.C). You need lists for the object and source files.
Topic archived. No new replies allowed.