|
发表于 2012-3-26 01:37:18
|
显示全部楼层
向2楼致敬。
应用程序和底层还是有区别的嘛。
偏向于平台的就学习Linux驱动开发,而学习应用程序开发话,和windows的流程上差不多。
就像helloworld一样,建个文件helloworld.c
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("....");
return 0;
}
写个makefile:
OBJS=helloworld
CC=gcc
all:
$(CC) helloworld.c -o $(OBJS)
.PHONY:
clean:
rm -rf $(OBJS)
然后make一下就可以执行二进制文件helloworld了。
如果是做驱动,也可以写个helloworld.c模块试试:
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
static int hello_init()
{
printk(KERN_ALERT "Hello, World!\n");
return 0;
}
static void hello_exit()
{
printk(KERN_ALERT "Goodbye, World!\n");
}
module_init(hello_init);
module_exit(hello_exit);
在建一个makefile:
obj-m := helloworld.o
kerneldir=/your/kernel/path
PWD=$(shell pwd)
all:
$(MAKE) -C $(kerneldir) M=$(PWD) modules
clean:
rm -rf helloworld
我觉得,如果楼主想开发一个能够接受网络包的程序,那么需要了解linux环境下的网络编程接口。
它和开发物理网卡驱动不是同一个东西。
就好比shell用的很溜,对于linux环境很熟悉。但是shell不用来开发内核,但是在linux下写程序,尤其是文本界面的时候,熟练应用shell又是推动作用吧。 |
|