易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux GCC make文件的写法3

 包含3个文件夹
目录组织结构如下:
inc/hello.h
main/main.c, Makefile
src/hello.c
文件内容如下:
hello.h:
void hello(char name[]);
main.c:
#include <stdio.h>
#include "../inc/hello.h"
// The second hello.h should in ""
int main()
{
hello("GCC");
printf("Haha Linux Ubuntu!\n");
return 0;
}
其中,第二个包含文件,hello.h,必须要用"",如果用<>则gcc只会到系统目录下去搜索,不会到本当前目录下搜索
就是""在用户目录下,<>在系统目录下,这个在windows上不严格, 在linux里似乎很严格
Makefile版本1:
# String declaration
objects = main.o hello.o
# Command
app : $(objects)
cc -o app $(objects)
main.o : main.c hello.h
cc -c main.c
hello.o : hello.c stdio.h
cc -c ../src/hello.c
# Search paths
vpath %.h /usr/include ../inc
vpath %.c ../src
# Clean the intermediate files
.PHONY : clean
clean :
rm app $(objects)
貌似vpath只对 %.o : 后面的有影响,下面的cc -c没有作用
**************************
确实是这样的,
%.o : %.c %.h,这句话是make的语句,而下面的
cc -c %.c,这句话是gcc的语句,
而vpath和VPATH设定的是make的搜索路径,对gcc的搜索路径没有影响。
gcc设置搜索路径为:
cc -c main.c -Iinclude
**************************
Makefile版本2:
# String declaration
objects = main.o hello.o
# Command
app : $(objects)
cc -o app $(objects)
main.o : main.c hello.h
cc -c main.c
hello.o : ../src/hello.c stdio.h
cc -c ../src/hello.c
# Search paths
vpath %.h /usr/include ../inc
#vpath %.c ../src
# Clean the intermediate files
.PHONY : clean
clean :
rm app $(objects)

hello.c:
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}


相关文档:

ubuntu 远程连接 linux 使用SSH (ubuntu 配置ssh服务)

安装OpenSSH
Ubuntu缺省没有安装SSH Server,使用以下命令安装:
sudo apt-get install openssh-server openssh-client
不过Ubuntu缺省已经安装了ssh client。
配置完成后重起:
sudo /etc/init.d/ssh restart
windows 客户端用putty连接命令shell模式
......

Linux驱动的一些基本操作

Linux驱动的一些基本操作

Linux内核中定义了很多宏,对硬件端口和寄存器进行操作,从网上搜集了一些宏定义的信息:
1. __REG简单的说就是获得后面所示物理地址映射后的虚拟地址,例如:
#define GPLR0  __REG(0x40E00000)    /* GPIO Pin-Level Register GPIO<31:0> */
#define GPL ......

linux查找最近修改的文件 并只拿出文件名

在服务器上写部署项目的脚本 ,需要把上传来的最新的项目解压, 部署 ,启动服务 实现自动化
于是找到最新的文件是第一件事情
就得到了以下脚本
$ ls -lrt | awk '/xmhi/ { f=$NF };END{ print f }'
中间的xmhi是文件所包含的字符串
另外如果要ls出所有的文件名
$ ls -l |awk '{print$9}' ......

Linux 2.6.19.x 内核编译配置选项简介

原文出处:http://www.svn8.com/shouce/Linux/kernel_options.html尊重原创!
Code maturity level options
代码成熟度选项
Prompt for development and/or incomplete code/drivers 显示尚在开发中或尚未完成的代码与驱动.除非你是测试人员或者开发者,否则请勿选择
General setup
常规设置
Local version - append ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号