关于做网站的问卷调查,网站建设项目表,东莞网络科技有限公司,做花生的网站1、生成可执行文件的makefile2、生成静态链接库的makefile3、生成动态链接库的makefile
本文把makefile 分成了三份#xff1a;生成可执行文件的makefile#xff0c;生成静态链接库的makefile#xff0c;生成动态链接库的makefile。 这些makefile都很简单#xff0c;一般都…1、生成可执行文件的makefile2、生成静态链接库的makefile3、生成动态链接库的makefile
本文把makefile 分成了三份生成可执行文件的makefile生成静态链接库的makefile生成动态链接库的makefile。 这些makefile都很简单一般都是一看就会用用法也很容易只需要把它们拷贝到你的代码的同一目录下然后就可以用 make 来生成目标文件了。 下面是三个makefile的源代码
回到顶部
1、生成可执行文件的makefile ######################################
#
######################################
#source file
#源文件自动找所有.c和.cpp文件并将目标定义为同名.o文件
SOURCE : $(wildcard *.c) $(wildcard *.cpp)
OBJS : $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))#target you can change test to what you want
#目标文件名输入任意你想要的执行文件名
TARGET : test#compile and lib parameter
#编译参数
CC : gcc
LIBS :
LDFLAGS :
DEFINES :
INCLUDE : -I.
CFLAGS : -g -Wall -O3 $(DEFINES) $(INCLUDE)
CXXFLAGS: $(CFLAGS) -DHAVE_CONFIG_H#i think you should do anything here
#下面的基本上不需要做任何改动了
.PHONY : everything objs clean veryclean rebuildeverything : $(TARGET)all : $(TARGET)objs : $(OBJS)rebuild: veryclean everythingclean :rm -fr *.sorm -fr *.overyclean : cleanrm -fr $(TARGET)$(TARGET) : $(OBJS)$(CC) $(CXXFLAGS) -o $ $(OBJS) $(LDFLAGS) $(LIBS) 回到顶部
2、生成静态链接库的makefile ######################################
#
#
#######################################target you can change test to what you want
#共享库文件名lib*.a
TARGET : libtest.a#compile and lib parameter
#编译参数
CC : gcc
AR ar
RANLIB ranlib
LIBS :
LDFLAGS :
DEFINES :
INCLUDE : -I.
CFLAGS : -g -Wall -O3 $(DEFINES) $(INCLUDE)
CXXFLAGS: $(CFLAGS) -DHAVE_CONFIG_H#i think you should do anything here
#下面的基本上不需要做任何改动了#source file
#源文件自动找所有.c和.cpp文件并将目标定义为同名.o文件
SOURCE : $(wildcard *.c) $(wildcard *.cpp)
OBJS : $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE))).PHONY : everything objs clean veryclean rebuildeverything : $(TARGET)all : $(TARGET)objs : $(OBJS)rebuild: veryclean everythingclean :rm -fr *.overyclean : cleanrm -fr $(TARGET)$(TARGET) : $(OBJS)$(AR) cru $(TARGET) $(OBJS)$(RANLIB) $(TARGET) 回到顶部
3、生成动态链接库的makefile ######################################
#
#
#######################################target you can change test to what you want
#共享库文件名lib*.so
TARGET : libtest.so#compile and lib parameter
#编译参数
CC : gcc
LIBS :
LDFLAGS :
DEFINES :
INCLUDE : -I.
CFLAGS : -g -Wall -O3 $(DEFINES) $(INCLUDE)
CXXFLAGS: $(CFLAGS) -DHAVE_CONFIG_H
SHARE : -fPIC -shared -o#i think you should do anything here
#下面的基本上不需要做任何改动了#source file
#源文件自动找所有.c和.cpp文件并将目标定义为同名.o文件
SOURCE : $(wildcard *.c) $(wildcard *.cpp)
OBJS : $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE))).PHONY : everything objs clean veryclean rebuildeverything : $(TARGET)all : $(TARGET)objs : $(OBJS)rebuild: veryclean everythingclean :rm -fr *.overyclean : cleanrm -fr $(TARGET)$(TARGET) : $(OBJS)$(CC) $(CXXFLAGS) $(SHARE) $ $(OBJS) $(LDFLAGS) $(LIBS)