libtool生成.a静态库 - ShenYj/ShenYj.github.io GitHub Wiki
-
在
OCStaticLib
文件夹中准备OCTest.h
和OCTest.m
两个简单的类文件. ├── OCTest.h └── OCTest.m
-
将
OCTest.m
编译成.o
目标文件终端进入到同级目录, 执行
clang
命令clang -x objective-c \ -target x86_64-apple-macos11.1 \ -fobjc-arc \ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk \ -c OCTest.m \ -o OCTest.o
编译后
. ├── OCTest.h ├── OCTest.m └── OCTest.o
- 参数说明:
-
-x
: 指定语言 -
-target
: 指定架构(指令集) -
-fobjc-arc
: 指定为ARC模式 -
-isysroot
: 指定SDK
的路径
-
- 参数说明:
-
将
OCTest.o
文件生成.a
静态库❯ libtool -static -o libTest.a test.o
-
libtool
参数说明-
-static
: 指定生成格式为静态库, 默认项
-
-
-
.a
静态库生成. ├── OCTest.h ├── OCTest.m ├── OCTest.o └── libOCTest.a