libjing 编译 for iphone simulator (..完善中..)

上面说道在mac下面编译成功,我们开始在iphone下面编译

********

修改main.scons的sdk (两处)

    '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk',
***************

在libjingle.scons中注释一下代码,因为ios不支持mac中的部分framework

# "base/macutils.cc",
# "base/proxydetect.cc",


1.

首先修改/ilibjingle/gtalk/libjingle-0.5/talk下面的main.scons,修改

'-isysroot', '/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk',

'-isysroot', '/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk',
或是对应其它版本的sdk,我刚开始没有修改,因此遇到了下面的问题:

MacmatoMacBook:talk Mac$ /swtoolkit/hammer.sh 
scons: Reading SConscript files ...
/swtoolkit/site_scons/site_tools/component_targets_msvs.py:34: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5

scons: warning: The build_dir keyword has been deprecated; use the variant_dir keyword instead.
File "/swtoolkit/site_scons/site_init.py", line 203, in BuildEnvironmentSConscripts
scons: done reading SConscript files.
scons: Building targets ...
________Compiling build/dbg/obj/third_party/expat-2.0.1/lib/xmlparse.o
third_party/expat-2.0.1/lib/xmlparse.c:5:20: error: stddef.h: No such file or directory
third_party/expat-2.0.1/lib/xmlparse.c:6:65: error: string.h: No such file or directory
third_party/expat-2.0.1/lib/xmlparse.c:7:20: error: assert.h: No such file or directory
third_party/expat-2.0.1/lib/xmlparse.c:8:55: error: limits.h: No such file or directory
third_party/expat-2.0.1/lib/xmlparse.c:9:53: error: time.h: No such file or directory
In file included from third_party/expat-2.0.1/lib/xmlparse.c:26:
third_party/expat-2.0.1/lib/expat.h:17:20: error: stdlib.h: No such file or directory
In file included from third_party/expat-2.0.1/lib/xmlparse.c:26:

在”FRAMEWORKS字段中,加入下面几个framework,(小心重复!)

 'CoreAudio', 'QuickTime', 'Cocoa', 'QTKit'


2.

将third_party中对应的“expat-2.0.1”,“openssl-1.0.0”,“srtp“拷贝过来,注意重命名。


现在/swtoolkit/hammer.sh 编译会出现错误:

scons: Building targets ...
________Compiling build/dbg/obj/base/openssladapter.o
base/openssladapter.cc:7:25: error: openssl/bio.h: No such file or directory
base/openssladapter.cc:8:28: error: openssl/crypto.h: No such file or directory
base/openssladapter.cc:9:25: error: openssl/err.h: No such file or directory
base/openssladapter.cc:10:30: error: openssl/opensslv.h: No such file or directory
base/openssladapter.cc:11:26: error: openssl/rand.h: No such file or directory
base/openssladapter.cc:12:25: error: openssl/ssl.h: No such file or directory
base/openssladapter.cc:13:28: error: openssl/x509v3.h: No such file or directory
base/openssladapter.cc:51: error: 'BIO' was not declared in this scope

不清楚原因,先往下面配置再说。

http://www.chinaunix.net/old_jh/15/578775.html

根据这篇博客执行命令,貌似有理,但依然失败

ln -s  /usr/local/ssl/include/openssl    /usr/include/openssl  
fix:

先将openssl编译,

  $ ./config
  $ make
  $ make test
  $ make install

然后在talk.Library(env, name = "libjingle", 中加入对应的include

       includedirs = [
               "third_party/expat-2.0.1/",
               "third_party/srtp/include",
               "third_party/srtp/crypto/include",
		"third_party/openssl-1.0.0/include",
             ],


******

Error:

________Linking build/dbg/obj/login
ld: warning: ignoring file build/dbg/lib/libcrypto.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file build/dbg/lib/libssl.a, file was built for archive which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
  "_BIO_clear_flags", referenced from:
      socket_write(bio_st*, char const*, int)in libjingle.a(openssladapter.o)
      socket_read(bio_st*, char*, int)in libjingle.a(openssladapter.o)
  "_BIO_set_flags", referenced from:
      socket_write(bio_st*, char const*, int)in libjingle.a(openssladapter.o)
      socket_read(bio_st*, char*, int)in libjingle.a(openssladapter.o)
fix:将刚刚编译的openssl找到对应的libcrypto.a,libssl.a,加入build/dbg/lib/中,

这个问题是刚才的openss是通过arm指令集编译的(我也忘了是什么时候编译的了),我们需要通过源码再i386下进行重新编译才行,--或许一直到ios真机的时候,还需要用arm重新编译
***



****

在 libjingle.scons 中,注释以下代码,因为IOS不支持这些(mac os x 上是支持的)

# "base/macutils.cc",
#  "session/phone/devicemanager_mac.mm",
#  "base/proxydetect.cc",


(2)Add some Header serach directory in includedirs.

like:

  includedirs = [
               "third_party/expat-2.0.1/",
               "third_party/srtp/include",
               "third_party/srtp/crypto/include",
               "third_party/openssl-1.0.0/include",
             ],
编译,出现以下错误:

________Compiling build/dbg/obj/session/phone/channel.o
________Compiling build/dbg/obj/session/phone/channelmanager.o
________Compiling build/dbg/obj/session/phone/codec.o
________Compiling build/dbg/obj/session/phone/devicemanager.o
cc1plus: warnings being treated as errors
session/phone/devicemanager.cc:833: warning: 'bool cricket::ShouldDeviceBeIgnored(const std::string&)' defined but not used
scons: *** [build/dbg/obj/session/phone/devicemanager.o] Error 1
scons: building terminated because of errors.
原因: gcc里如果加上 -Werror 来严格检查编译环境使用它能够使gcc产生告警也认为是错误

方案:修改main.scons中,注释”# '-Werror',“

 # '-Werror',

继续编译,出现新问题:

_______Compiling build/dbg/obj/base/unixfilesystem.o
In file included from base/unixfilesystem.cc:39:
/ilibjingle/gtalk/libjingle-0.5/talk/base/macutils.h:43: error: 'EventRef' was not declared in this scope
base/unixfilesystem.cc: In member function 'virtual bool talk_base::UnixFilesystem::GetTemporaryFolder(talk_base::Pathname&, bool, const std::string*)':
base/unixfilesystem.cc:174: error: aggregate 'FSRef fr' has incomplete type and cannot be defined
base/unixfilesystem.cc:175: error: 'kOnAppropriateDisk' was not declared in this scope
base/unixfilesystem.cc:175: error: 'kTemporaryFolderType' was not declared in this scope
base/unixfilesystem.cc:176: error: 'kCreateFolder' was not declared in this scope
base/unixfilesystem.cc:176: error: 'FSFindFolder' was not declared in this scope
base/unixfilesystem.cc:179: error: 'FSRefMakePath' was not declared in this scope
base/unixfilesystem.cc: In member function 'virtual bool talk_base::UnixFilesystem::GetAppPathname(talk_base::Pathname*)':
base/unixfilesystem.cc:355: error: 'kCurrentProcess' was not declared in this scope
base/unixfilesystem.cc:357: error: 'kProcessDictionaryIncludeAllInformationMask' was not declared in this scope
base/unixfilesystem.cc:357: error: 'ProcessInformationCopyDictionary' was not declared in this scope
base/unixfilesystem.cc:361: error: 'kIOBundleExecutableKey' was not declared in this scope
base/unixfilesystem.cc: In member function 'virtual bool talk_base::UnixFilesystem::GetAppDataFolder(talk_base::Pathname*, bool)':
base/unixfilesystem.cc:387: error: aggregate 'FSRef fr' has incomplete type and cannot be defined
base/unixfilesystem.cc:388: error: 'kUserDomain' was not declared in this scope
base/unixfilesystem.cc:388: error: 'kApplicationSupportFolderType' was not declared in this scope
base/unixfilesystem.cc:389: error: 'kCreateFolder' was not declared in this scope
base/unixfilesystem.cc:389: error: 'FSFindFolder' was not declared in this scope
base/unixfilesystem.cc:392: error: 'FSRefMakePath' was not declared in this scope
scons: *** [build/dbg/obj/base/unixfilesystem.o] Error 1

FSFindFolder是在CoreService.framework中声明的,iphoneSimulator中是有的,或许是其它问题

kOnAppropriateDisk在simulator中没有生命,而在mac os x 的sdk中生命了,因此把他注释掉。因此我判断是两者sdk不兼容的问题,

EventRef 再整个文件系统中找不到对应定义的地方,但读文档和源码(NSEvent),知道他是只支持 10.5以上的sdk,因此ios不兼容

解决方案,(但可能会留下问题):注释 libjingle.scons中的下面句子,是上面报错的语句不再执行

 #       "base/unixfilesystem.cc",

此问题解决,但出现了新问题:

________Compiling build/dbg/obj/examples/call/voicemailjidrequester.o
________Linking build/dbg/obj/call
Undefined symbols for architecture i386:
  "vtable for talk_base::UnixFilesystem", referenced from:
      talk_base::UnixFilesystem::UnixFilesystem()in libjingle.a(fileutils.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
scons: *** [build/dbg/obj/call] Error 1
scons: building terminated because of errors.


“UnixFilesystem” 虽然我已经注释掉了,但是libjingle.a是我在mac下的libjingle编译后直接copy过来的,因此mac下会用到“UnixFilesystem”因此产生冲突,我需要自己在ilibjingle下重新编译出libjingle.a才行。


发现 “/ilibjingle/gtalk/libjingle-0.5/talk/build/dbg/lib”下面的文件,出了libcryto和libssl是openssl编译创建然后copy过来的,剩下的都是在“/swtoolkit/hammer.sh”时候创建的


还是没有头绪,随便测试,这时候进入openssl,进行make编译,出现以下错误,不知道是否和现在的环境有关,同时在mac上的成功 libjingle 编译,也会出现同样的错误,不知道什么原因

AN -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DWHIRLPOOL_ASM   -c -o ts.o ts.c
cc -DMONOLITH -I.. -I../include  -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DWHIRLPOOL_ASM   -c -o openssl.o openssl.c
rm -f openssl
shlib_target=; if [ -n "" ]; then \
		shlib_target="darwin-shared"; \
	fi; \
	LIBRARIES="-L.. -lssl  -L.. -lcrypto" ; \
	make -f ../Makefile.shared -e \
		APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o" \
		LIBDEPS="-Wl,-search_paths_first $LIBRARIES " \
		link_app.${shlib_target}
( :; LIBDEPS="${LIBDEPS:--Wl,-search_paths_first -L.. -lssl  -L.. -lcrypto }"; LDCMD="${LDCMD:-cc}"; LDFLAGS="${LDFLAGS:--DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DWHIRLPOOL_ASM}"; LIBPATH=`for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o ${LIBDEPS} )
ld: in ../libcrypto.a, malformed archive TOC entry for _PEM_write_DHparams, offset 1919315554 is beyond end of file 2393928
 for architecture i386
collect2: ld returned 1 exit status
make[2]: *** [link_app.] Error 1
make[1]: *** [openssl] Error 2
make: *** [build_apps] Error 1

删除gdb下面的所有库,重新copy新的openssl,再进行编译试试

还是不行,编译错误,先不管。

**

上面的方案不对,

再报错文件unixfilesystem.cc 中,找到对应的代码,看到是定义了OSX才调用FSFindFolder,

#ifdef OSX
  FSRef fr;
  if (0 != FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType,
                        kCreateFolder, &fr))
    return false;
  unsigned char buffer[NAME_MAX+1];
原因找到了,我们再main.scons中注视到对应变量

mac_env.Append(
  CPPDEFINES = [
   # 'OSX',
    'MAC_OS_X_VERSION_MIN_REQUIRED=1040',
  ],
**
Error

base/physicalsocketserver.cc: In static member function 'static int talk_base::PhysicalSocket::TranslateOption(talk_base::Socket::Option, int*, int*)':
base/physicalsocketserver.cc:495: error: 'IP_MTU_DISCOVER' was not declared in this scope
scons: *** [build/dbg/obj/base/physicalsocketserver.o] Error 1

和上面是同样的问题,同样方法,找到错误文件,发现:

#elif defined(OSX) || defined(BSD)
        LOG(LS_WARNING) << "Socket::OPT_DONTFRAGMENT not supported.";
        return -1;
#elif defined(POSIX)
        *slevel = IPPROTO_IP;
        *sopt = IP_MTU_DISCOVER;
        break;
#endif
原因找到了,我们再main.scons中注视到对应变量

posix_env.Append(
  CPPDEFINES = [
    'HASHNAMESPACE=__gnu_cxx',
    'HASH_NAMESPACE=__gnu_cxx',
  #  'POSIX',	//这里或许会有错误,等编译结束再看看
    'DISABLE_DYNAMIC_CAST',
    'HAVE_OPENSSL_SSL_H=1',
  ],
出现错误:

________Compiling build/dbg/obj/base/asynchttprequest.o
In file included from /ilibjingle/gtalk/libjingle-0.5/talk/base/asynchttprequest.h:32,
                 from base/asynchttprequest.cc:28:
/ilibjingle/gtalk/libjingle-0.5/talk/base/event.h:36:2: error: #error "Must define either WIN32 or POSIX."
In file included from /ilibjingle/gtalk/libjingle-0.5/talk/base/httpcommon.h:37,
                 from /ilibjingle/gtalk/libjingle-0.5/talk/base/httpbase.h:35,

证明此方案行不通,再想办法吧

***

最终 xcode 中Header Search Paths 配置微

 /..../talk/third_party/srtp/crypto/include/ --ok
/..../talk/third_party/srtp/include/  --ok
/..../talk/third_party/expat-2.0.1/  --ok
/..../talk/third_party/openssl-1.0.0/include/  --ok  ----需要重命名
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/ 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/

**

Error:

_______Compiling build/dbg/obj/base/unixfilesystem.o
In file included from base/unixfilesystem.cc:39:
/ilibjingle/gtalk/libjingle-0.5/talk/base/macutils.h:43: error: 'EventRef' was not declared in this scope
base/unixfilesystem.cc: In member function 'virtual bool talk_base::UnixFilesystem::GetTemporaryFolder(talk_base::Pathname&, bool, const std::string*)':
base/unixfilesystem.cc:174: error: aggregate 'FSRef fr' has incomplete type and cannot be defined
base/unixfilesystem.cc:175: error: 'kOnAppropriateDisk' was not declared in this scope
base/unixfilesystem.cc:175: error: 'kTemporaryFolderType' was not declared in this scope
fix:修改main.scons,该mac为ios ( 可能出错)

mac_env.Append(
  CPPDEFINES = [
    'IOS',
    'MAC_OS_X_VERSION_MIN_REQUIRED=1040',
  ],
**

Error

________Compiling build/dbg/obj/base/physicalsocketserver.o
base/physicalsocketserver.cc: In static member function 'static int talk_base::PhysicalSocket::TranslateOption(talk_base::Socket::Option, int*, int*)':
base/physicalsocketserver.cc:495: error: 'IP_MTU_DISCOVER' was not declared in this scope
scons: *** [build/dbg/obj/base/physicalsocketserver.o] Error 1
scons: building terminated because of errors.

fix:

        #       "base/physicalsocketserver.cc",

**

Error

________Compiling build/dbg/obj/session/phone/devicemanager.o
session/phone/devicemanager.cc:98: error: 'bool cricket::GetVideoDevices(std::vector<cricket::Device, std::allocator<cricket::Device> >*)' used but never defined
session/phone/devicemanager.cc:833: warning: 'bool cricket::ShouldDeviceBeIgnored(const std::string&)' defined but not used
scons: *** [build/dbg/obj/session/phone/devicemanager.o] Error 1

fix

#     "session/phone/devicemanager.cc",

**

Error

________Compiling build/dbg/obj/base/macutils.o
In file included from base/macutils.cc:32:
/ilibjingle/gtalk/libjingle-0.5/talk/base/macutils.h:43: error: 'EventRef' was not declared in this scope
base/macutils.cc:87: error: redefinition of 'std::string talk_base::DecodeEvent'
/ilibjingle/gtalk/libjingle-0.5/talk/base/macutils.h:43: error: 'std::string talk_base::DecodeEvent' previously declared here
base/macutils.cc:87: error: 'EventRef' was not declared in this scope
base/macutils.cc: In function 'bool talk_base::GetGestalt(OSType, int*)':
base/macutils.cc:98: error: 'Gestalt' was not declared in this scope
base/macutils.cc: In function 'bool talk_base::GetOSVersion(int*, int*, int*)':
base/macutils.cc:111: error: 'gestaltSystemVersion' was not declared in this scope
base/macutils.cc:119: error: 'gestaltSystemVersionMajor' was not declared in this scope
base/macutils.cc:120: error: 'gestaltSystemVersionMinor' was not declared in this scope
base/macutils.cc:121: error: 'gestaltSystemVersionBugFix' was not declared in this scope
base/macutils.cc: In function 'bool talk_base::GetQuickTimeVersion(std::string*)':
base/macutils.cc:145: error: 'gestaltQuickTimeVersion' was not declared in this scope
scons: *** [build/dbg/obj/base/macutils.o] Error 1
scons: building terminated because of errors.

fix:

#     "base/macutils.cc",


















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值