文档介绍:Linux 内核实验
周戎
大纲
1 编程基础
2 Linux内核文件
3 实验
如何在Linux下面编译一个程序?
如何编译一个静态链接库?
如何安装驱动?
:编译器
Gcc,G++
GCC stands for "piler Collection". GCC is an integrated distribution pilers for several major programming languages. Most of pilers for languages other than C have their own names. The C++ compiler is G++, the piler is GNAT, and so on.
Gcov
gcov is a test coverage program. Use it in concert with GCC to analyze your programs to help create more efficient, faster running code and to discover untested parts of your program.
World
#include <iostream>
int main()
{
using namespace std;
cout << “Hello World”<<endl;
return 0;
}
G++ –O2
gcc -E -o
gcc -c -o
gcc -o hello
对应Windows的DLL技术
工具: Gcc
主程序
Linux下的调用
myfunc=dlopen("./",RTLD_LAZY);
externfunction=dlsym(myfunc,"demoadd");
externfunction(10,5);
dlclose(myfunc);
gcc -Wall -O2 -c -fPIC
gcc -shared -o
gcc –Wall –O2 -o app -ldl
:Windows下面调用动态库
HMODULE LoadLibrary( LPCTSTR lpFileName );
FARPROC GetProcAddress( HMODULE hModule, LPCSTR ame );
BOOL FreeLibrary( HMODULE hModule );
查看设备类型
From windows
From Linux (lspci,lsusb)
From OEM List ( Dell, Lenovo)
得到驱动源代码
Vendor Source (cdrom/ floopy)
Website
Linux forum
编译
Make
安装
Make install?
Manual install
Linux内核
我们为什么要编译内核?
内核版本
内核结构
各部分解释
开始编译