Eclipse Create makefile Project generates multiple execution files

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.