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

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. android: 调用摄像头拍照

    很多应用程序都可能会使用到调用摄像头拍照的功能,比如说程序里需要上传一张图片 作为用户的头像,这时打开摄像头拍张照是最简单快捷的.下面就让我们通过一个例子来学 习一下,如何才能在应用程序里调用手机的摄 ...

  2. android: 内容提供器简介

    我们学了 Android 数据持久化的技术,包括文件存储.SharedPreferences 存 储.以及数据库存储.不知道你有没有发现,使用这些持久化技术所保存的数据都只能在当 前应用程序中访问.虽 ...

  3. 配置CENTOS YUM更新源

    众所周知,Centos 有个很方便的软件安装工具  yum,但是默认安装完centos,系统里使用的是国外的centos更新源,这就造成了我们使用默认更新源安装或者更新软件时速度很慢的问题. 为了使用 ...

  4. SFTP+OpenSSH+ChrootDirectory设置

    账户设置 SFTP的账户直接使用Linux操作系统账户,我们可以用useradd命令来创建账户. 首先建立3个要管理的目录:   1 2 3 mkdir /home/sftp/homepage mkd ...

  5. Lotus Domino中使用Xpage技术打造通讯录

    我们来完成一个类似通讯录的功能,我们可以添加人员,查看和修改,删除人员,我们假设我们的通讯录中只记录人员的名字和年龄字段.先看看完成后的效果吧 点击New可以到新增人员页面,如下图: 编辑按钮后进入编 ...

  6. 完美解决 向UILable 文字最后插入N张图片,支持向限制行数的UILable 最后一行插入,多余文字显示...

    效果: ====直接上代码吧=== // // UILabel+StringFrame.h // QYER // // Created by qyer on 15/3/19. // Copyright ...

  7. java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting

    将原有项目图片加载框架picasso改为glide,关于picasso和glide文档就自行查阅相关资料 显示 图片 例子 Glide.with(mContext).load(imageUrl).pl ...

  8. 关于SQLServer2008数据如何导入SQL2005的解决办法,高版本数据导入低版本中。

    最近需要把SqlServer2008 的数据库导入sqlserver2005 中.直接备份还原肯定不行.后来想到可以生成脚本执行sql语句,并选择数据可以一同进行执行. 点击右键--->任务-- ...

  9. C# inline-hook / api-hook

    我查阅了一下相关C#方面的资料,却没有发现有提供过关于api-hook方面的资 料包括应用库由此本人编写一套inline-hook的库用于支持x64.x86上的基于在 clr的公共语言,如: c#.c ...

  10. mediawiki的安装与配置

    apache的配置: 1. 开启php module 查看mods-enabled/php5.load 是否存在,不存在的话, 就从mods-avaliable中复制一个到mods-enabled中. ...