PROTOBUF compilation on MAC

Source: Internet
Author: User
Tags curl

#!/bin/bash# anthology replaced with Https://github.com/google/protobuf/releases/tag/v2.6.1echo Building Google protobuf for Mac OS X/ Ios.echo use ' tail-f build.log ' to monitor progress. (prefix= ' pwd '/protobufmkdir ${prefix}mkdir ${prefix}/platformxcodedir= ' xcode-select--print-path ' MACOSX_PLATFORM= ${xcodedir}/platforms/macosx.platformmacosx_sysroot=${macosx_platform}/developer/macosx10.9.sdkiphoneos_ platform=${xcodedir}/platforms/iphoneos.platformiphoneos_sysroot=${iphoneos_platform}/developer/sdks/ iphoneos7.0.sdkiphonesimulator_platform=${xcodedir}/platforms/iphonesimulator.platformiphonesimulator_sysroot= ${iphonesimulator_platform}/developer/sdks/iphonesimulator7.0.sdkcc=clangcflags= "-dndebug-g-o0-pipe-fpic- Fcxx-exceptions "cxx=clang++cxxflags=" ${cflags}-std=c++11-stdlib=libc++ "##################################### Cleanup any earlier build attempts#################################### (cd/tmp if [-D ${prefix}] then R M-RF ${prefix} fi mkdir ${prefix} mkdir ${prefix}/Platform) ########################################### Fetch Google protobuf 2.5.0 from source.####################### ################### (cd/tmp Curl http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz--output/tmp/protobuf- 2.5.0.tar.gz if [-d/tmp/protobuf-2.5.0] then rm-rf/tmp/protobuf-2.5.0 fi tar xvf/tmp/protobuf     -2.5.0.tar.gz) ###################### x86_64 for Mac OS x##################### (cd/tmp/protobuf-2.5.0 make Distclean ./configure--disable-shared--prefix=${prefix}--exec-prefix=${prefix}/platform/x86_64 "CC=${CC}" "CFLAGS=${CFLAGS }-arch x86_64 "" Cxx=${cxx} "" Cxxflags=${cxxflags}-arch x86_64 "Make make test make install) #################### ######## i386 for IPhone simulator########################### (cd/tmp/protobuf-2.5.0 make Distclean./configure --build=x86_64-apple-darwin13.0.0--host=i386-apple-darwin13.0.0--with-protoc=${prefix}/platform/x86_64/bin/ Protoc--disable-shared--prefix=${prefix}--eXec-prefix=${prefix}/platform/i386 "CC=${CC}" "Cflags=${cflags}-miphoneos-version-min=6.1-arch i386-isysroot ${ Iphonesimulator_sysroot} "" Cxx=${cxx} "" Cxxflags=${cxxflags}-arch i386-isysroot ${iphonesimulator_sysroot} "LDFLAGS    = "-arch i386-miphoneos-version-min=6.1" make do install) ################### armv7 for iphone################## ( cd/tmp/protobuf-2.5.0 make Distclean./configure--build=x86_64-apple-darwin13.0.0--host=armv7-apple-darwin13.0. 0--with-protoc=${prefix}/platform/x86_64/bin/protoc--disable-shared--prefix=${prefix}--exec-prefix=${PREFIX}/ Platform/armv7 "CC=${CC}" "Cflags=${cflags}-miphoneos-version-min=6.1-arch armv7-isysroot ${IPHONEOS_SYSROOT}" "CXX =${cxx} "" Cxxflags=${cxxflags}-arch armv7-isysroot ${iphoneos_sysroot} "ldflags="-arch armv7-miphoneos-version-min= 6.1 "Make do Install" #################### armv7s for iphone################### (cd/tmp/protobuf-2.5.0 make Distclean./configure--build=x86_64-apple-darwin13.0.0--host=armv7s-apple-darwin13.0.0--with-protoc=${prefix}/platform/x86_64/bin/protoc--disable-shared--prefix =${prefix}--exec-prefix=${prefix}/platform/armv7s "CC=${CC}" "Cflags=${cflags}-miphoneos-version-min=6.1-arch Armv7s-isysroot ${iphoneos_sysroot} "" Cxx=${cxx} "" Cxxflags=${cxxflags}-arch armv7s-isysroot ${IPHONEOS_SYSROOT} " ldflags= "-arch armv7s-miphoneos-version-min=6.1" make make install) ######################################### Patch Protobuf 2.5.0 for 64bit support######################################## (cd/tmp/protobuf-2.5.0 make Distclean C URL https://gist.github.com/bennettsmith/7111094/raw/171695f70b102de2301f5b45d9e9ab3167b4a0e8/0001- Add-generic-gcc-support-for-atomic-operations.patch--output/tmp/0001- Add-generic-gcc-support-for-atomic-operations.patch Curl https://gist.github.com/BennettSmith/7111094/raw/ A4e85ffc82af00ae7984020300db51a62110db48/0001-add-generic-gcc-header-to-makefile.am.patch--output/tmp/0001- Add-generic-gcc-header-tO-makefile.am.patch Patch-p1 </tmp/0001-add-generic-gcc-support-for-atomic-operations.patch PATCH-P1 </tmp /0001-add-generic-gcc-header-to-makefile.am.patch rm/tmp/0001- Add-generic-gcc-support-for-atomic-operations.patch Rm/tmp/0001-add-generic-gcc-header-to-makefile.am.patch) # # # ################ arm64 for iphone################## (cd/tmp/protobuf-2.5.0./configure--build=x86_64-apple-darwin1 3.0.0--host=arm--with-protoc=${prefix}/platform/x86_64/bin/protoc--disable-shared--prefix=${PREFIX}-- Exec-prefix=${prefix}/platform/arm64 "CC=${CC}" "Cflags=${cflags}-miphoneos-version-min=6.1-arch arm64-isysroot ${ Iphoneos_sysroot} "" Cxx=${cxx} "" Cxxflags=${cxxflags}-arch arm64-isysroot ${iphoneos_sysroot} "LDFLAGS="-arch arm64- miphoneos-version-min=6.1 "Make make Install" ############################# Create Universal libraries############### ############# (CD ${prefix}/platform mkdir Universal Lipo X86_64/LIB/LIBPROTOBUF.A Arm64/lib/libprotobUF.A armv7s/lib/libprotobuf.a ARMV7/LIB/LIBPROTOBUF.A i386/lib/libprotobuf.a-create-output UNIVERSAL/LIBPROTOBUF.A Lipo X86_64/lib/libprotobuf-lite.a Arm64/lib/libprotobuf-lite.a Armv7s/lib/libprotobuf-lite.a armv7/lib/ Libprotobuf-lite.a i386/lib/libprotobuf-lite.a-create-output universal/libprotobuf-lite.a) ###################### # # # Finalize the packaging######################## (CD ${prefix} mkdir bin mkdir lib Cp-r platform/x86_64/b In/protoc bin Cp-r platform/x86_64/lib/* Lib Cp-r platform/universal/* Lib Rm-rf platform)) >build.log 2&gt ; &1echo done!

  

PROTOBUF compilation on MAC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.