1、使用eclipse生成静态库
如图 new --> C++ project --> Static Library -->next --> finish
完成编程后,点击 build 即在Debug 下看到 生成的 .a 文件 即是想要得到的静态库
2、静态库的使用
使用eclipse添加自己的静态库 暂时不会 方法行不通 有待后续解决
现使用手动方式:
将静态库及其相关的头文件拷贝到同一文件夹下,并在此文件夹下创建 mian.c
注:mian.c内需包含所需要的头文件。
g++ mian.c libs.a //当前目录下编译生成 a.out,已连接静态库文件
./a.out //运行程序
3、使用eclipse生成C/C++ .so 工程
file --> new C++ project --> Shared Library --> Empty Project + Linux GCC --> Finish //工程创建完成
xxxx --> Properties --> a、C/C++ Build --> Setting --> Tool Setting --> GCC C/C++ Compiler --> Command ="gcc/g++ -fPIC" //增加makefile命令
b、C/C++ Generall --> Paths and Symbols --> Libraries --> add dl
完成上述步骤后即可,编写文件,build project 生成 xxx.so