标签:
IOS交叉编译
1.android版本 vqmon已经正常运行,现需要开放IOS版本,作移植工作。
2. 注意事项: 1)ROOT权限,IOS必须越狱。
2)依赖库:pcap, ffmpeg,libes, libxml2, libz,
3) iphone手机越狱,远程ssh登录
3.开放环境:
xcode:6.1.1 mac-mini: 10.1.9
clang: Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
SDK:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
iPhoneOS6.1.sdk
iPhoneOS7.0.sdk
iPhoneOS8.1.sdk
选用8.1
4. makefile编写
IOS_BASE_SDK=8.1 IOS_DEPLOY_TGT=7.1 DEVROOT = $(shell xcode-select -p)/Platforms/iPhoneOS.platform/Developer SDKROOT = $(DEVROOT)/SDKs/iPhoneOS$(IOS_BASE_SDK).sdk CC = clang -isysroot ${SDKROOT} AR = $(DEVROOT)/usr/bin/ar ARCH = -arch armv7 -arch armv7s -arch arm64 -mios-version-min=7.0 CFLAGS := -g -O0 -I../include XML_INCLUDE=-I/usr/include/libxml2 XML_LIB=-L/usr/lib -lxml2 CFLAGS += -Wall -g -O2 -I ../include -I ../src -I"." -I"/Users/chulk/iosVqmon/data/dependencies/include" -D_GNU_SOURCE CFLAGS+=$(XML_INCLUDE) LDFLAGS = -lm -lz LDFLAGS +=-L/usr/lib/ LDFLAGS += $(XML_LIB) LDFLAGS += ../bin/libmt.a LDFLAGS += ../bin/libes.a LDFLAGS += ../bin/libpcap.a LDFLAGS += ../bin/libffmpeg.a STRIP = strip RM = /bin/rm -f TARGET = qos all: $(TARGET) SOURCE = tcp.c dissector.c hash.c user_pcap.c util.c interface.c main.c OBJS = $(SOURCE:%.c=obj/%.o) $(TARGET): $(OBJS) $(CC) $(ARCH) -g $(OBJS) $(LDFLAGS) -o $@ cp -f $(TARGET) ../bin obj/%.o:%.c @mkdir -p obj $(CC) $(ARCH) $(CFLAGS) -c $< -o $@ clean: rm -rf obj $(OBJS) $(TARGET)
$(shell xcode-select -p) 目录是:/Applications/Xcode.app/Contents/Developer
-isysroot ${SDKROOT} 将ROOT目录切换到${SDKROOT} ,即/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk。后续操作/usr/lib,/usr/include都是相对此目录。
在/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/目录下存在多个iPhoneOs的多个版本iPhoneOS6.1.sdk,iPhoneOS7.0.sdk,iPhoneOS8.1.sdk等不同sdk版本。
/Applications/Xcode.app/Contents/Developer/Platforms 下区分不同平台,MacOSX.platform,iPhoneOS.platform,iPhoneSimulator.platform.此处选择iPhoneOS.platform开放平台。
/usr/lib下存在libz.dylib, libxml2.dylib ,libm.dylib 动态库,故可直接调用。pcap, ffmpeg,libes得重新编译!
ARCH = -arch armv7 -arch armv7s -arch arm64 -mios-version-min=7.0 -arch指定支持的cpu架构。 -mios-version-min=7.0表示只支持7.0(含)以上的版本系统(iPhoneOS)。
5.编译pcap
直接运行build-libpcap.sh 生成iPhoneOS版本。 脚本需要修改版本。
https://github.com/chrisballinger/openvpn-server-ios/blob/master/build-libpcap.sh
6.编译 ffmpeg, es
7注意:
make期间出现过 "Unsupported architecture" 错误,是因为pcap的头文件路径不对,指到了系统的其他目录,不匹配,应该指到生成的交叉编译版本。
标签:
原文地址:http://www.cnblogs.com/iclk/p/4330895.html