1.编写Makefile主文件
#project include config #
include Makefile.common.variables
LINKING=$(CC) $(CFLAGS) $(LIBS) -lpthread -o $@ $(notdir $^) -L../lib/ -lpcre
VPATH = ../
INCLUDES= -I../ -I../include
DEFS = -DNO_SOUND -DNO_ACC_BACKUP -DISDTLIB
LIBS = -L../lib
CFLAGS = $(CFLAGS1) $(DEFS) $(INCLUDES)
# here list all the source files
SOURCES = mynet.cpp
TEST_SOURCES = server.cpp
OBJECT = $(SOURCES:%.cpp=%.o)
ALL_OBJS = $(notdir $(OBJECT))
TEST_OBJS = server.o
# here list all the target binary files
build:testServer
# here list all the linking dependencies
testServer: $(OBJECT) $(TEST_OBJS)
$(LINKING)
clean: ; rm -f *.o testServer
-include Makefile.dep
.PHONY : clean all dep
%.o:%.cpp
@echo Compile c++ file $<, `more $<|wc -l` lines ....
$(CC) -c $(CFLAGS) $<
%.o:%.c
@echo Compile c file $<, `more $<|wc -l` lines ....
$(CC) -c $(CFLAGS) $<
2.编写include文件Makefile.common.variable
#CFLAGS1 = -g -Wall -Wno-deprecated
#CFLAGS1 = -O2 -Wall -Wno-deprecated -fPIC
CFLAGS1 = -std=c++11 -O2 -g -Wall -Wno-deprecated -fPIC
CFLAGS1 += -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
CXXFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
#CFLAGS1 = -O2 -Wall -Wno-deprecated -fPIC
#CC = gcc
CC = g++
IPPROUT = ./lib
3.在安装GCC的linux机器上编译
make