编译命令

创建静态库

libtool -static -arch_only x86_64 a.o -o a.a

libtool -static -arch_only arm64 -D -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.plat form/Developer/SDKs/iPhoneOS13.6.sdk test.o -o libTest.a

创建动态库

clang -dynamiclib -target arm64-apple-ios13.5 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhon eOS.platform/Developer/SDKs/iPhoneOS13.6.sdk a.o -o a.dylib

ar命令

ar压缩目标文件,并对其进行编号和索引,形成静态库。同时也可以解压缩静态库,查看有哪些目标文件:

ar -rc a.a a.o

  • -r: 像a.a添加or替换文件
  • -c: 不输出任何信息
  • -t: 列出包含的目标文件

合并静态库

libtool -static -o   

clang 命令参数:

clang命令参数:
     -x: 指定编译文件语言类型
     -g: 生成调试信息
     -c: 生成目标文件,只运行preprocess,compile,assemble,不链接
     -o: 输出文件
     -isysroot: 使用的SDK路径
     1. -I 在指定目录寻找头文件 header search path
     2. -L 指定库文件路径(.a\.dylib库文件) library search path
     3. -l 指定链接的库文件名称(.a\.dylib库文件)other link flags -lAFNetworking
     -F 在指定目录寻找framework framework search path
     -framework  指定链接的framework名称 other link flags -framework AFNetworking
     

install_name_tool命令

install_name_tool -add_rpath  libs_File 
install_name_tool -delete_rpath  libs_File 
install_name_tool -rpath   libs_File

编译优化设置

优化⽬标 可⽤的优化级别
较⼩的代码尺⼨ -Oz
性能优先,性能更⾼ -Oz, -O3, -Ofast
调试优先 -O1
更快的编译和构建时间 -O0
平衡代码⼤⼩和编译性能 -Os

你可能感兴趣的:(编译命令)