|
|
发表于 2005-9-27 09:58:21
|
显示全部楼层
Post by rickxbx
- [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
复制代码
这个都知道
想看你的静态连接不用共享库  |
|