1. Create a Makefile Project
2. Create the INC src Debug directory
Used to store header file source files
3. Writing makefile
Need to target the makefile file in the active file, give a template that generates two targets as follows
############################################################################## #sourcefile#源文件, automatically find all. C and. cpp files and define the target as the same name. o File Source:= $ (wildcard *.c) $ (wildcard *.CPP) Objs:= $ (patsubst%.c,%.o,$ (patsubst%).CPP,%. o,$ (SOURCE))) #target You can change test to the want# target file name, enter any executable file name you want target:=Client Server APP1:=clientAPP2:=Servermains:=$ (APP1). O $ (APP2). O#compile and Lib parameter# compile parameter cc:= g++LIBS:=-LPTHREAD-LRT-Leventldflags:=-l/usr/local/libevent/Libdefines:=INCLUDE:=-I.-i./inc-i/usr/local/libevent/Includecflags:=-g-wall-O3 $ (defines) $ (INCLUDE) Cxxflags:= $ (CFLAGS)-dhave_config_h#i Think you should Doanything here# The following basically does not need to make any changes. Phony:everything OBJS Clean rebuildeverything: $ (target) All: $ (target) OBJS: $ (OBJS) Rebuild:veryclean Everythingclean : RM-FR *. soRM-FR *. ORM-fr./debug/$ (APP1)RM-fr./debug/$ (APP2) $ (APP1): $ (APP1). O $ (Filter-Out $ (MAINS), $ (OBJS)) $ (CC) $ (cxxflags)-O./debug/[email protected] $^$ (ldflags) $ (LIBS) $ (APP2): $ (APP2). O $ (Filter-Out $ (MAINS), $ (OBJS)) $ (CC) $ (cxxflags)-O./debug/[email protected] $^ $ (ldflags) $ (LIBS)
Note: Configure the header file directory link library directory link library name
4. Configure the Eclipse Index directory
At this point, if the makefile configuration is correct, can compile normally, but in eclipse because there is no configuration header file directory, some library functions will not be found, need to make the following configuration
Eclipse Create makefile Project generates multiple execution files