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

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. 设想 Docker 下部署 KVM

    设想 Docker 下部署 KVM 一.安装 $ yum -y install kvm # kvm base , must $ yum -y install libvirt -y # libvirtd ...

  2. S2SH框架的集成

    S2SH框架的集成 20131130 代码下载 : 链接: http://pan.baidu.com/s/1sz6cQ 密码: 513t 这一个星期的时间里,学习SSH框架技术,首先因为之前的项目用到 ...

  3. discuz x3在DIY模块中调用伪静态不成功,显示动态链接的解决办法

    discuz x3在DIY模块中调用伪静态不成功,显示动态链接,然而其他的链接正常显示伪静态. 后台启用伪静态后,发现论坛版块.帖子点击链接,伪静态正常显示,然后在门户首页DIY显示的帖子,点进去后发 ...

  4. 发布EWM RF ITS Mobile 相关服务

    发布EWM RF ITS Mobile 相关服务 TCODE:SIAC_PUBLISH_ALL_INT ~XSRFCHECK = 0 SICF 参数: ~THEME     99 ~TRANSACTI ...

  5. 实现多项式的JAVA类

                                   p = coef[i] + (x * p);               }                           Poly ...

  6. [Aaronyang] 写给自己的WPF4.5 笔记18[几何图形*Geometry图文并茂讲解]

    为什么要掌握?因为WPF 3D知识很多与它Geometry对比,所以我要系统学一下. --学会用Geometry给Path的Data属性填充. 图形可以转换成路径,Path的值,当然你也可以直接使用R ...

  7. CSS3学习笔记--transform基于原始数据(旋转木马实例)

    参考链接:好吧,CSS3 3D transform变换,不过如此! transform-style:preserve-3d属性要在图片所在的容器(父元素)中定义,perspective定义在父子元素上 ...

  8. [转]SQL SERVER – Find Most Expensive Queries Using DMV

    转自:http://blog.sqlauthority.com/2010/05/14/sql-server-find-most-expensive-queries-using-dmv/ The tit ...

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

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

  10. 同步与异步&阻塞与非阻塞

    摘要 一直为同步异步,阻塞非阻塞概念所困扰,特定总结了下,原来是这么个意思 一直为同步异步,阻塞非阻塞概念所困扰,特定总结了下 一.同步与异步的区别 1.概念介绍 同步:所谓同步是一个服务的完成需要依 ...