以两个链接打开序幕,镇楼。

c++神之博客链表:那些C++牛人的博客

各个branch的学习指导:程序员技术练级攻略

A Simple Makefile Tutorial

Official menu: GNU make

Ref: 山寨内核Makefile之“天龙八部”

一个简单例子:

CC=gcc
CFLAGS=-I.
DEPS = hellomake.h
OBJ = hellomake.o hellofunc.o %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) hellomake: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS)

一个复杂例子:

IDIR=../include
CC=gcc
CFLAGS=-I$(IDIR)  #指定了头文件 ODIR=obj
LDIR=../lib LIBS=-lm _DEPS = hellomake.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) _OBJ = hellomake.o hellofunc.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) $(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) hellomake: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) .PHONY: clean clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~

如果.cpp在不同的目录级别呢?也就是:多个文件目录下Makefile的写法

From: 多文件工程的编译-Makefile的简便写法

CC = gcc
CFLAGS = -Isub -Iadd -O2  
OBJS = add_int.o add_float.o sub_int.o sub_float.o main.o
TARGET = cacu
RM = rm -f
$(TARGET):$(OBJS)
  $(CC) -o $(TARGET) $(OBJS) $(CFLAGS)
$(OBJS):%.o:%.c
  $(CC) -c $(CFLAGS) $< -o $@
clean:
  -$(RM) $(TARGET) $(OBJS)

一个原始的"笨"写法:

#生成test,":"左边为目标,右边为依赖 。gcc后是命令
cacu:add_int.o add_float.o sub_int.o sub_float.o main.o
gcc -o cacu add/add_int.o add/add_float.o \ (连接符)
sub_int.o sub_float.o main.o
#生成add_int.o的规则
add_int.o:add/add_int.c add/add_int.h
gcc -c -o add/add_int.o add/add_int.c
#生成add_float.o的规则
add_float.o:add/add_float.c add/add_float.h
gcc -c -o add/add_float.o add/add_float.c
#生成sub_int.o的规则
sub_int.o:sub/sub_int.c sub/sub_int.h
gcc -c -o sub/sub_int.o sub/sub_int.c
#生成sub_float.o的规则
sub_float.o:sub/sub_float.c sub/sub_float.h
gcc -c -o sub/sub_float.o sub/sub_float.c
#生成main.o的规则
main.o:main.c add/add.h sub/sub.h
gcc -c-o main.o main.c -Iadd -Isub
#清理的规则
clean:
rm -f test add_int.o add_float.o sub_int.o \
sub_float.o main.o

如果要写wraper,注意extern c,需要注释掉。

否则导致函数名因为重载机制而链接出问题。

[c++] Collection of key and difficult points的更多相关文章

  1. Max Points on a Line

    Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. ...

  2. [C3] Andrew Ng - Neural Networks and Deep Learning

    About this Course If you want to break into cutting-edge AI, this course will help you do so. Deep l ...

  3. Beginning Scala study note(6) Scala Collections

    Scala's object-oriented collections support mutable and immutable type hierarchies. Also support fun ...

  4. 115 Java Interview Questions and Answers – The ULTIMATE List--reference

    In this tutorial we will discuss about different types of questions that can be used in a Java inter ...

  5. Notes for "Python in a Nutshell"

    Introduction to Python Wrap C/C++ libraries into Python via Cython and CFFI. Python implementations ...

  6. 转 What is Redis and what do I use it for?

    原文: http://stackoverflow.com/questions/7888880/what-is-redis-and-what-do-i-use-it-for Redis = Remote ...

  7. mongo_action

    https://docs.mongodb.com/manual/introduction/ { name: "sue", age: 3, status: "A" ...

  8. 【读书笔记】《Computer Organization and Design: The Hardware/Software Interface》(1)

    笔记前言: <Computer Organization and Design: The Hardware/Software Interface>,中文译名,<计算机组成与设计:硬件 ...

  9. 【转帖】Service Discovery: 6 questions to 4 experts

    https://highops.com/insights/service-discovery-6-questions-to-4-experts/ What’s Service Discovery? I ...

随机推荐

  1. Revit API 楼板开洞

    start [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] , , ) *  / , - ...

  2. 无线电源传输 Wireless Power Consortium (WPC) Communication

    Universally Compatible Wireless Power Using the Qi Protocol Wireless charging of portable electronic ...

  3. 使用 Aircrack-ng 破解 WEP 和 WPA/WPA2 加密的 Wi-Fi 密码。(转)

    1.首先请不要使用此方法去搞破坏,去蹭Wi-Fi,因为不装逼地说,我认为技术本身的价值很大,尤其是在学习这个技术的过程中解决遇到的问题,当经过重重困难最后终于成功之后的喜悦又怎么能拿去蹭网呢.我在此过 ...

  4. mysql5.5 uuid做主键与int做主键的性能实测

    数据库:mysql5.5 表类型:InnoDB 数据量:100W条 第一种情况: 主键采用uuid 32位. 运行查询语句1:SELECT COUNT(id) FROM test_varchar; 运 ...

  5. atmega32u4制作arduino leonardo最小系统

    转载请注明:@小五义http://www.cnblogs.com/xiaowuyiQQ群:64770604 一.leonardo最小系统 关于leonardo这里不再介绍,直接上最小系统原理图,该系统 ...

  6. BW CUBE 数据的聚集和压缩

    大家都知道,压缩和聚集都是提高bw性能的方法,在新版bw里,压缩名称改成了折叠,聚集放在了滚动菜单里---集合.那么我们在使用这两种方法时需要注意的先创建聚集以后,再进行压缩,因为压缩的过程是把F表的 ...

  7. web端视频直播网站的弊端和优势

    在YY上市前后,国内涌出一批类YY视频直播或9158的秀场类网站. 比如六间房,酷六等等 这种web端视频服务基本依靠web本身的特性,用flash直播,靠CDN提供服务. 但是这样的架构有2个问题 ...

  8. IPv6 app适配

    参考资料: https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/Network ...

  9. 前端经常使用插件使用文档 以及demo

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...

  10. 【原】Jqxgrid在Java服务器端分页

    研究这个后台分页一天多,特此写个文章记录备忘 jsp页面中有两个需要注意的地方:一个是source中beforeprocessing,另一个是rendergridrows中数据的获取. 说明:grid ...