angelpan1014

 

2012年12月21日

网址

摘要: http://www.cnblogs.com/mumuliang/archive/2011/05/31/2064837.html 阅读全文

posted @ 2012-12-21 16:43 angelpan1014 阅读(106) 评论(0) 推荐(0) 编辑

2012年10月30日

20121030

摘要: ocs8:/home/panpan/C++>lshello.cpp hello.h main.cpp Makefileocs8:/home/panpan/C++>cat -n hello.cpp 1 #include <iostream> 2 using namespace std; 3 void hello(const char*name) 4 { 5 6 cout<<"hello"<<name<<endl; 7 }ocs8:/home/panpan/C++>cat -n hello.h 1 //#ifnd 阅读全文

posted @ 2012-10-30 16:00 angelpan1014 阅读(316) 评论(0) 推荐(0) 编辑

2012年10月25日

编译.so .a的结果

摘要: ocs52:/home2/billing/panpan/C++>lshello hello.cpp hello.h hello.o libhello.a libhello.so libwpp.a main.cpp main.oocs52:/home2/billing/panpan/C++>nm hello.o U __cxa_atexit U __dso_handle000000000000003e t _GLOBAL__I__Z5helloPKc U __gxx_personality_v00000000000000054 t __tcf_00000000000000000 t 阅读全文

posted @ 2012-10-25 14:38 angelpan1014 阅读(721) 评论(0) 推荐(0) 编辑

/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld:

摘要: 场景:/usr/lib64/gcc/x86_64-suse-linux/4.1.2/http://www.cnblogs.com/http://www.cnblogs.com/x86_64-suse-linux/bin/ld: hello.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIChello.o: could not read symbols: Bad value别人的错误:/usr/bin/ld: 阅读全文

posted @ 2012-10-25 14:22 angelpan1014 阅读(7469) 评论(0) 推荐(0) 编辑

20121025

摘要: hello.c hello.h libhello.so main.c static_lib_demoocs8:/home/panpan/C++>gcc -o hello main.c -L. -lhello/tmp/ccoy9enl.o: In function `main':main.c:(.text+0xa): undefined reference to `hello'collect2: ld returned 1 exit statusocs8:/home/panpan/C++>gcc -o hello main.c -L. -lhello/tmp/ccMV 阅读全文

posted @ 2012-10-25 10:29 angelpan1014 阅读(196) 评论(0) 推荐(0) 编辑

2012年10月24日

2

摘要: collect2: ld returned 1 exit statusocs8:/home/panpan/C++>gcc -shared -fPCI -o libhello.so hello.o/usr/lib64/gcc/x86_64-suse-linux/4.1.2/http://www.cnblogs.com/http://www.cnblogs.com/x86_64-suse-linux/bin/ld: hello.o: relocation R_X86_64_32 against `a local symbol' can not be used when making 阅读全文

posted @ 2012-10-24 18:06 angelpan1014 阅读(406) 评论(0) 推荐(0) 编辑

2012年10月23日

20121023

摘要: gcc 生成 .a静态库和 .so动态库 我们通常把一些公用函数制作成函数库,供其它程序使用。函数库分为静态库和动态库两种。静态库在程序编译时会被连接到目标代码中,程序运行时将不再需要该静态库。动态库在程序编译时并不会被连接到目标代码中,而是在程序运行是才被载入,因此在程序运行时还需要动态库存在。本文主要通过举例来说明在Linux中如何创建静态库和动态库,以及使用它们。在创建函数库前,我们先来准备举例用的源程序,并将函数库的源程序编译成.o文件。第1步:编辑得到举例的程序--hello.h、hello.c和main.c;hello.c(见程序2)是函数库的源程序,其中包含公用函数hello,该 阅读全文

posted @ 2012-10-23 21:54 angelpan1014 阅读(344) 评论(0) 推荐(0) 编辑

2012年10月21日

ldd 和ar 用法

摘要: 下面是ar命令的格式: ar [-]{dmpqrtx}[abcfilNoPsSuvV] [membername] [count] archive files... 例如我们可以用ar rv libtest.a hello.o hello1.o来生成一个库,库名字是test,链接时可以用-ltest链接。该库中存放了两个模块hello.o和hello1.o。选项前可以有‘-’字符,也可以没有。下面我们来看看命令的操作选项和任选项。现在我们把{dmpqrtx}部分称为操作选项,而[abcfilNoPsSuvV]部分称为任选项。 {dmpqrtx}中的操作选项在命令中只能并且必须使用其中一个... 阅读全文

posted @ 2012-10-21 22:18 angelpan1014 阅读(253) 评论(0) 推荐(0) 编辑

ldd 和ar

摘要: 1.ar基本用法2.nm基本用法命令 当我们的程序中有经常使用的模块,而且这种模块在其他程序中也会用到,这时按照软件重用的思想,我们应该将它们生成库,使得以后编程可以减少开发代码量。这里介绍两个命令ar和nm,用来对库操作。 1.ar基本用法 ar命令可以用来创建、修改库,也可以从库中提出单个模块。库是一单独的文件,里面包含了按照特定的结构组织起来的其它的一些文件(称做此库文件的member)。原始文件的内容、模式、时间戳、属主、组等属性都保留在库文件中。 下面是ar命令的格式:ar [-]{dmpqrtx}[abcfilNoPsSuvV] [membername] [count] a.. 阅读全文

posted @ 2012-10-21 22:17 angelpan1014 阅读(194) 评论(0) 推荐(0) 编辑

.cpp 编译成.a或是 .so

摘要: 1.将.c 文件编译成.o文件gcc -c test1.c test2.c test3.c2.然后用ar命令生成.a文件,ar crv test.a test1.o test2.o test3.o3.在windows环境,我们有集成开发环境(IDE),使得我们对编译器了解的很少。当我们专向linux时需要在命令行下编译自己的程序需要对编译器的命令行参数比较熟悉。而如果是做嵌入开发构建自己的操作系统时失去了系统平台,需要我们对编译的过程以及可执行文件的内部结构有所了解。本文讲述了如何编译可执行文件、静态库、动态库,如何优化编译器,如何编译无操作系统环境下的程序(自己的OS)等。 ... 阅读全文

posted @ 2012-10-21 22:09 angelpan1014 阅读(1172) 评论(0) 推荐(0) 编辑

导航