|
|
发表于 2005-9-26 22:50:12
|
显示全部楼层
Post by zhllg
关于这一点
如果你确认可行的话
不妨举个例子出来
包括简单的源文件和命令
- [rick@Fedora-Core test]$ cat so.c
- int __add(int a,int b)
- {
- return a+b;
- }
- [rick@Fedora-Core test]$ gcc -fPIC -shared so.c -o libso.so
- [rick@Fedora-Core test]$ su
- Password:
- [root@Fedora-Core test]# cp libso.so /lib/
- [root@Fedora-Core test]# cat api.c
- extern int __add(int,int);
- int _add(int a,int b)
- {
- return __add(a,b);
- }
- [root@Fedora-Core test]# gcc -fPIC -shared -lso api.c -o libapi.so
- [root@Fedora-Core test]# cat test.c
- #include <stdio.h>
- extern int _add(int,int);
- int main()
- {
- printf("%d\n",_add(1,2));
- }
- [root@Fedora-Core test]# gcc ./libapi.so test.c -o test
- [root@Fedora-Core test]# ./test
- 3
复制代码 |
|