[c++] Collection of key and difficult points
以两个链接打开序幕,镇楼。
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的更多相关文章
- 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. ...
- [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 ...
- Beginning Scala study note(6) Scala Collections
Scala's object-oriented collections support mutable and immutable type hierarchies. Also support fun ...
- 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 ...
- Notes for "Python in a Nutshell"
Introduction to Python Wrap C/C++ libraries into Python via Cython and CFFI. Python implementations ...
- 转 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 ...
- mongo_action
https://docs.mongodb.com/manual/introduction/ { name: "sue", age: 3, status: "A" ...
- 【读书笔记】《Computer Organization and Design: The Hardware/Software Interface》(1)
笔记前言: <Computer Organization and Design: The Hardware/Software Interface>,中文译名,<计算机组成与设计:硬件 ...
- 【转帖】Service Discovery: 6 questions to 4 experts
https://highops.com/insights/service-discovery-6-questions-to-4-experts/ What’s Service Discovery? I ...
随机推荐
- iframe 使用
iframe框架中的页面与主页面之间的通信方式根据iframe中src属性是同域链接还是跨域链接,有明显不同的通信方式,同域下的数据交换和DOM元素互访就简单的多了,而跨域的则需要一些巧妙的方式来实现 ...
- linux中touch命令参数修改文件的时间戳(转)
linux中touch命令参数不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件,以下是linux中touch命令参数的使用方法: touch [-acm][-r ...
- 我所理解的JavaScript闭包
目录 一.闭包(Closure) 1.1.什么是闭包? 1.2.为什么要用闭包(作用)? 1.2.1.保护函数内的变量安全. 1.2.2.通过访问外部变量,一个闭包可以暂时保存这些变量的上下文环境,当 ...
- 架设证书服务器 及 让IIS启用HTTPS服务(转)
无废话图文教程,教你一步一步搭建CA服务器,以及让IIS启用HTTPS服务. 一.架设证书服务器(CA服务) 1.在系统控制面板中,找到“添加/删除程序”,点击左侧的“添加/删除windows组件”, ...
- Python学习笔记(4):自定义时间类
Python的时间我实在无法接受,太难用了.我觉得C#的时间就非常完美,简单.好用.所以,自定义了自己的时间类: 用法: 一个小小的应用,我需要取出每天股市交易的分钟段,开始是这样的: 稍微改进一下, ...
- C#--GDI+的LinearGradientBrush类
命名空间:System.Drawing.Drawing2D LinearGradientBrush对象用颜色线性渐变填充图形.简言之,颜色渐变包含一种在两种指定的颜色之间渐变的颜色,渐变的方向是沿着指 ...
- Dell U2913WM使用感受
21:9比例,本来想代替双屏的,一周用下来还是不适应,如何能弯成曲面就爽了.感觉最舒服的还是以前19寸5:4双屏,点距大. 还尝试在旁边立个23寸,看了15分钟就受不了,头晕. 漏光,还行. 加了个A ...
- Microsoft Fakes
http://baike.baidu.com/view/9602275.htm?fr=aladdin http://technet.microsoft.com/zh-cn/magazine/hh549 ...
- Storage Systems topics and related papers
In this post, I will distill my own ideas and my own views into a structure for a storage system cou ...
- 20个最漂亮的基于WordPress的企业网站
20个最漂亮的基于WordPress的企业网站 每个人都知道很好很强大的WordPress是开源的,并且有一个很强的的团队和更强大的支持社区.它被世界上的广大设计师.程序员和商业人员广泛使用.它已经成 ...