Thread: Makefiles

  1. #1
    Registered User
    Join Date
    Apr 2010


    hi, below is a makefile which im using to link all object files into one program. I think im just compiling each file and not linking them, can anybody help me with linking these files into one program. (ps this is my first makefile)
    LIBS = -lfltk -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 $(LIBS2)
    LIBS2 = -L$(IBASE)/lib -Wl,--start-group -lamq_common -lamq_wireapi -lapr -laprutil -lasl -lgsl3 -lgsl -licl -lipr -lopf -lpcre -lsfl -lsmt3 -lsmt -lzip -lrt -lcrypt -lpthread -lm  -Wl,--end-group
    LDPATH = -L/usr/local/lib 
    CPP = g++
    CC = gcc
    CFLAGS = -D_REENTRANT -D_GNU_SOURCE -Wall -Wno-unused -fno-strict-aliasing  -DBASE_THREADSAFE 
    INC = -I. -I/usr/local/include -I. -I$(IBASE)/include
    all: 		cursor im_sender im_receiver
    cursor: 	cursor.o im_sender.o im_receiver.o
    		$(CPP) -o cursor cursor.o im_sender.o im_receiver.o $(LDPATH) $(LIBS)
    cursor.o: 	cursor.cxx cursor.h
    		$(CPP) -c $(INC) cursor.cxx 
    im_sender: 	im_sender.o
    		$(CC) -o im_sender im_sender.o $(LIBS2)
    im_receiver: 	im_receiver.o
    		$(CC) -o im_receiver im_receiver.o $(LIBS2)
    im_sender.o: 	im_sender.c cursor.h
    		$(CC) $(CFLAGS) $(INC) -c im_sender.c 
    im_receiver.o: 	im_receiver.c cursor.h
    		$(CC) $(CFLAGS) $(INC) -c im_receiver.c
    		rm -f *.o
    		rm -f cursor im_sender im_receiver

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    You're making three executables: cursor, im_sender, and im_receiver. If each of them have a main, then this is exactly what's supposed to happen.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefiles in windows
    By njitram2000 in forum C Programming
    Replies: 7
    Last Post: 02-16-2010, 09:17 AM
  2. Makefiles
    By TriKri in forum Windows Programming
    Replies: 3
    Last Post: 03-30-2008, 06:57 AM
  3. Benefits of makefiles
    By Ganoosh in forum C++ Programming
    Replies: 2
    Last Post: 06-27-2005, 09:42 PM
  4. programming linux with gcc, emacs, and makefiles
    By Captain Penguin in forum Linux Programming
    Replies: 1
    Last Post: 11-02-2002, 12:04 PM
  5. Help with Makefiles
    By WebmasterMattD in forum Linux Programming
    Replies: 3
    Last Post: 05-24-2002, 08:51 AM