您当前的位置: 首页 > 

第一次自己生成静态库

发布时间:2013-06-05 20:20:57 ,浏览量:0

只有一个别人的静态库,要实现静态库的功能,就是不知道人家内部是咋个实现的。

nm只能看到人家的几个封装好的函数,人家到底是自己实现的呢,还是调用第三方库呢?

如果是调用了第三方库,那么就应该可以看到第三方库中的函数。因为第三方库提供的是头文件,作为外部符号出现。

现在看不到符号,如果确实用了第三方库,那么就是把自己的代码放在了第三方库的源码中,封装了第三方库出来,

root@Ubuntu32:/home/zhangbin/Downloads# cd ..

root@Ubuntu32:/home/zhangbin# ls android                Documents         mp4             STM codeStore              Downloads         Music           streaming Desktop                examples.desktop  Pictures        Templates doBuildAndroidVLc.sh   ffmpeg            Public          Videos doBuildAndroidVLc.sh~  gstreamer         Source Insight  vlc root@Ubuntu32:/home/zhangbin# cd codeStore/ root@Ubuntu32:/home/zhangbin/codeStore# cd testCODE/ root@Ubuntu32:/home/zhangbin/codeStore/testCODE# ls testAndroidCode  testAndroidVLC  testDEPHOME  testLibcode  testStaticLib root@Ubuntu32:/home/zhangbin/codeStore/testCODE# cd testStaticLib/ root@Ubuntu32:/home/zhangbin/codeStore/testCODE/testStaticLib# ls main.c  main.c~  test.c  test.c~  test.h  test.h~ root@Ubuntu32:/home/zhangbin/codeStore/testCODE/testStaticLib# gcc -o test test.c test.c: In function ‘zhangbinTEST’: test.c:9:7: error: expected ‘:’ or ‘...’ before ‘;’ token test.c:11:5: error: break statement not within loop or switch test.c:12:1: error: case label not within a switch statement test.c:14:6: error: break statement not within loop or switch test.c:15:1: error: ‘default’ label not within a switch statement test.c:17:5: error: break statement not within loop or switch root@Ubuntu32:/home/zhangbin/codeStore/testCODE/testStaticLib# gcc -o test test.c test.c: In function ‘zhangbinTEST’: test.c:9:7: error: expected ‘:’ or ‘...’ before ‘;’ token test.c:11:5: error: break statement not within loop or switch test.c:12:1: error: case label not within a switch statement test.c:14:6: error: break statement not within loop or switch test.c:15:1: error: ‘default’ label not within a switch statement test.c:17:5: error: break statement not within loop or switch root@Ubuntu32:/home/zhangbin/codeStore/testCODE/testStaticLib# gcc -o test test.c test.c: In function ‘zhangbinTEST’: test.c:10:8: error: expected ‘:’ or ‘...’ before ‘;’ token root@Ubuntu32:/home/zhangbin/codeStore/testCODE/testStaticLib# gcc -o test test.c /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function `_start': (.text+0x18): undefined reference to `main'  可执行文件必须要有main collect2: ld returned 1 exit status root@Ubuntu32:/home/zhangbin/codeStore/testCODE/testStaticLib# gcc -o test.o -c test.c root@Ubuntu32:/home/zhangbin/codeStore/testCODE/testStaticLib# ar libtest.a test.o ar: invalid option -- 'e' Usage: ar [emulation options] [-]{dmpqrstx}[abcDfilMNoPsSTuvV] [--plugin] [member-name] [count] archive-file file...        ar -M [
关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    114465博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0765s