Results 1 to 2 of 2
I have written a console program in C named main.c.
I want to turn it into an application, so that using a Makefile and 'make' and 'make install' commands one ...
- 10-12-2011 #1
Creating Makefiles in Linux for installing programs
I have written a console program in C named main.c.
I want to turn it into an application, so that using a Makefile and 'make' and 'make install' commands one is able to install that in his/her computer.
Any ideas how to do that? I have searched tutorials for making the Makefile but they just tell me the way to compile the source files, not "install" them.
PS, I use Fedora 15 and Code::Blocks Ide, if that is of any help.
PPS : I have seen that copying the executable produced by gcc to /usr/bin directory does has the same result as installing. Is that what 'make install' command does?
- 10-12-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
Create a Makefile and put it in the same dir as your *.c file. Here's a very basic example of a Makefile:
It will compile myprog.c into a binary named myprog when you run "make". It will copy it to the $BINDIR location (which you can specify various ways) when you run "make install"Code:CC = /usr/bin/gcc STRIP = /usr/bin/strip SRC = myprog.c OBJ = myprog.o EXE = myprog .c.o: $(INC) $(CC) $(CFLAGS) -c $*.c all: $(EXE) $(STRIP) $(EXE) clean: rm -f *.o rm -f *% $(EXE) $(EXE): $(OBJ) $(CC) -o $(EXE) $(OBJ) $(LIBS) install : cp $(EXE) $(BINDIR)


Reply With Quote