File Usage:
- To build the code executable copy the make file to your source code location ((.cpp, .h)) and directly hit the "make" command.
- if you are trying to build the static library (.a) then make sure the the file having the "main" function should be removed first. then hit "make static".
- if you are trying to build the shared library (.so) then make sure the the file having the "main" function should be removed first. then hit "make shared"
# Purpose : Sample MakeFile that can ber used to build you c++ code
#
# Author : Saurabh Gupta
#
# Date Created : 25-02-2010
#
# Date Modified : 27-07-2011
#
# Note : 1. make : to build exe
# 2. make static : to build static library (remove main function first)
# 3. make shared : to build shared library (remove main function first)
#
# Usage : change the "EXE" to your program name or else use as it is
#
######################################################################################
MAKE = make
CXX = c++
CXXFLAGS = -O2 -g
LINK = -pedantic -Wall -lstdc++ -lpthread -ldl -lm -Wl,-rpath,.
COMPILE = -g -O0 -D_THREAD_SAFE -pedantic -Wall -c -Wno-deprecated
EXE = ./myProgram
static = libmyProgram.a
shared = libmyProgram.so
SRCS = $(shell ls *.cpp)
OBJS = $(subst .cpp,.o,$(SRCS))
.SUFFIXES: .o .cpp
.cpp.o:
$(CXX) $(CXXFLAGS) $(COMPILE) $<
all: $(OBJS)
$(CXX) $(OBJS) -o $(EXE) $(LINK)
-include depend.mak
depend:
g++ -MM $(SRCS) > depend.mak
static:
ar -crvs $(a) $(OBJS)
shared: $(OBJS)
$(CXX) -shared -Wl,-soname -lc -o $(so) $(OBJS)
clean:
rm -rf $(OBJS) depend.mak $(EXE) $(so) $(a)
hi,
ReplyDeletecan u provide a make file for c especially ?
sure asap.
ReplyDelete--Saurabh Gupta
please find the make file for c @
ReplyDeletehttp://saurabhgupta0527.blogspot.com/2011/10/makefile-for-c_12.html
nice it worked fine. thanks buddy.
ReplyDeleteHi,
ReplyDeleteDo u offer any class room trainings for C++?
Hi,
DeleteWe are sorry to say that currently there is no such plan for training.
Thanks,
Saurabh Gupta
saurabh.gupta@ccplusplus.com