snappy 我這裏就不作介紹了,直接能夠移步 https://github.com/google/snappy/tree/master 查看源碼及說明信息。html
我這裏下載 :https://github.com/google/snappy/releases/download/1.1.4/snappy-1.1.4.tar.gzgit
接下來執行編譯和安裝:github
1. 首先對文件進行解壓縮:vim
liuweideMacBook-Pro:opensource liuweiryan$ tar -zxvf snappy-1.1.4.tar.gz x snappy-1.1.4/ x snappy-1.1.4/AUTHORS x snappy-1.1.4/COPYING x snappy-1.1.4/ChangeLog x snappy-1.1.4/Makefile.am x snappy-1.1.4/NEWS x snappy-1.1.4/README x snappy-1.1.4/autogen.sh x snappy-1.1.4/configure.ac x snappy-1.1.4/format_description.txt x snappy-1.1.4/framing_format.txt x snappy-1.1.4/m4/ x snappy-1.1.4/m4/gtest.m4 x snappy-1.1.4/snappy-c.cc x snappy-1.1.4/snappy-c.h x snappy-1.1.4/snappy-internal.h x snappy-1.1.4/snappy-sinksource.cc x snappy-1.1.4/snappy-sinksource.h x snappy-1.1.4/snappy-stubs-internal.cc x snappy-1.1.4/snappy-stubs-internal.h x snappy-1.1.4/snappy-stubs-public.h.in x snappy-1.1.4/snappy-test.cc x snappy-1.1.4/snappy-test.h x snappy-1.1.4/snappy.cc x snappy-1.1.4/snappy.h x snappy-1.1.4/snappy.pc.in x snappy-1.1.4/snappy_unittest.cc x snappy-1.1.4/testdata/ x snappy-1.1.4/testdata/alice29.txt x snappy-1.1.4/testdata/asyoulik.txt x snappy-1.1.4/testdata/baddata1.snappy x snappy-1.1.4/testdata/baddata2.snappy x snappy-1.1.4/testdata/baddata3.snappy x snappy-1.1.4/testdata/fireworks.jpeg x snappy-1.1.4/testdata/geo.protodata x snappy-1.1.4/testdata/html x snappy-1.1.4/testdata/html_x_4 x snappy-1.1.4/testdata/kppkn.gtb x snappy-1.1.4/testdata/lcet10.txt x snappy-1.1.4/testdata/paper-100k.pdf x snappy-1.1.4/testdata/plrabn12.txt x snappy-1.1.4/testdata/urls.10K liuweideMacBook-Pro:opensource liuweiryan$ cd snappy-1.1.4 liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ls AUTHORS snappy-internal.h COPYING snappy-sinksource.cc ChangeLog snappy-sinksource.h Makefile.am snappy-stubs-internal.cc NEWS snappy-stubs-internal.h README snappy-stubs-public.h.in autogen.sh snappy-test.cc configure.ac snappy-test.h format_description.txt snappy.cc framing_format.txt snappy.h m4 snappy.pc.in snappy-c.cc snappy_unittest.cc snappy-c.h testdata
2. 編譯安裝windows
在這裏他提供了一個 autogen.sh 安裝腳本,咱們直接使用該腳本便可:bash
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ./autogen.sh ./autogen.sh: line 3: aclocal: command not found
執行後,這裏提供缺乏 aclocal 。對此進行安裝便可,該包是由 automake 提供的,接下來安裝 automake 包:app
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ brew install automake ==> Installing dependencies for automake: autoconf ==> Installing automake dependency: autoconf ==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/au ######################################################################## 100.0% ==> Pouring autoconf-2.69.high_sierra.bottle.4.tar.gz ==> Caveats Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/autoconf ==> Summary /usr/local/Cellar/autoconf/2.69: 71 files, 3.0MB ==> Installing automake ==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/au ######################################################################## 100.0% ==> Pouring automake-1.16.1_1.high_sierra.bottle.tar.gz /usr/local/Cellar/automake/1.16.1_1: 131 files, 3.4MB ==> Caveats ==> autoconf Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/autoconf
安裝完成後,接着咱們繼續執行 ./autogen.sh 腳本。ide
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ./autogen.sh ./autogen.sh: line 10: libtoolize: command not found liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$
擦擦,這裏有缺了,接着繼續安裝便可:工具
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ brew install libtool ==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/li ######################################################################## 100.0% ==> Pouring libtool-2.4.6_1.high_sierra.bottle.tar.gz ==> Caveats In order to prevent conflicts with Apple's own libtool we have prepended a "g" so, you have instead: glibtool and glibtoolize. ==> Summary /usr/local/Cellar/libtool/2.4.6_1: 71 files, 3.7MB
終於安裝完了,咱們繼續執行安裝腳本,執行後有報錯了(以下信息,這是第三個錯誤了):oop
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ./autogen.sh ./autogen.sh: line 10: libtoolize: command not found liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ brew install libtool ==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/li ######################################################################## 100.0% ==> Pouring libtool-2.4.6_1.high_sierra.bottle.tar.gz ==> Caveats In order to prevent conflicts with Apple's own libtool we have prepended a "g" so, you have instead: glibtool and glibtoolize. ==> Summary /usr/local/Cellar/libtool/2.4.6_1: 71 files, 3.7MB liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ./autogen.sh glibtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, '.'. glibtoolize: copying file './ltmain.sh' glibtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'. glibtoolize: copying file 'm4/libtool.m4' glibtoolize: copying file 'm4/ltoptions.m4' glibtoolize: copying file 'm4/ltsugar.m4' glibtoolize: copying file 'm4/ltversion.m4' glibtoolize: copying file 'm4/lt~obsolete.m4' configure.ac:17: installing './compile' configure.ac:17: installing './config.guess' configure.ac:17: installing './config.sub' configure.ac:15: installing './install-sh' configure.ac:15: installing './missing' Makefile.am: installing './INSTALL' /usr/local/Cellar/automake/1.16.1_1/share/automake-1.16/am/ltlibrary.am: warning: 'libsnappy.la': linking libtool libraries using a non-POSIX /usr/local/Cellar/automake/1.16.1_1/share/automake-1.16/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac' Makefile.am:4: while processing Libtool library 'libsnappy.la' Makefile.am: installing './depcomp' parallel-tests: installing './test-driver' configure.ac:43: error: possibly undefined macro: AC_DEFINE If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. configure.ac:45: error: possibly undefined macro: AC_MSG_FAILURE
經百度後,說是缺乏 pkg-config 包,咱們直接安裝便可
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ brew install pkg-config ==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/pk ######################################################################## 100.0% ==> Pouring pkg-config-0.29.2.high_sierra.bottle.tar.gz /usr/local/Cellar/pkg-config/0.29.2: 11 files, 627.2KB liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$
再次執行,報錯以下:
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ./autogen.sh /usr/local/Cellar/automake/1.16.1_1/share/automake-1.16/am/ltlibrary.am: warning: 'libsnappy.la': linking libtool libraries using a non-POSIX /usr/local/Cellar/automake/1.16.1_1/share/automake-1.16/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac' Makefile.am:4: while processing Libtool library 'libsnappy.la'
工具錯誤提示,須要在 configure.ac 文件中,增長 AM_PROG_AR,咱們使用 vim 編輯 configure.ac 這個文件,以下圖:
接着再執行 ./autogen.sh 腳本文件(編譯經過):
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ./autogen.sh liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$
接下來,咱們進入正式安裝環節,根目錄下執行 ./configure 命令:
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... ./install-sh -c -d checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports the include directive... yes (GNU style) checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking whether gcc understands -c and -o together... yes checking dependency style of gcc... gcc3 checking for ar... ar checking the archiver (ar) interface... ar checking build system type... x86_64-apple-darwin17.7.0 checking host system type... x86_64-apple-darwin17.7.0 checking how to print strings... printf checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 196608 checking how to convert x86_64-apple-darwin17.7.0 file names to x86_64-apple-darwin17.7.0 format... func_convert_file_noop checking how to convert x86_64-apple-darwin17.7.0 file names to toolchain format... func_convert_file_noop checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for archiver @FILE support... no checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking for sysroot... no checking for a working dd... /bin/dd checking how to truncate binary pipes... /bin/dd bs=4096 count=1 checking for mt... no checking if : is a manifest tool... no checking for dsymutil... dsymutil checking for nmedit... nmedit checking for lipo... lipo checking for otool... otool checking for otool64... no checking for -single_module linker flag... yes checking for -exported_symbols_list linker flag... yes checking for -force_load linker flag... yes checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... yes checking for gcc option to produce PIC... -fno-common -DPIC checking if gcc PIC flag -fno-common -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin17.7.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking dependency style of g++... gcc3 checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fno-common -DPIC checking if g++ PIC flag -fno-common -DPIC works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin17.7.0 dyld checking how to hardcode library paths into programs... immediate checking whether byte ordering is bigendian... no checking for size_t... yes checking for ssize_t... yes checking for stdint.h... (cached) yes checking stddef.h usability... yes checking stddef.h presence... yes checking for stddef.h... yes checking sys/mman.h usability... yes checking sys/mman.h presence... yes checking for sys/mman.h... yes checking sys/resource.h usability... yes checking sys/resource.h presence... yes checking for sys/resource.h... yes checking windows.h usability... no checking windows.h presence... no checking for windows.h... no checking byteswap.h usability... no checking byteswap.h presence... no checking for byteswap.h... no checking sys/byteswap.h usability... no checking sys/byteswap.h presence... no checking for sys/byteswap.h... no checking sys/endian.h usability... no checking sys/endian.h presence... no checking for sys/endian.h... no checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for mmap... yes checking for 'gtest-config'... checking for gtest-config... no no checking for pkg-config... /usr/local/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for libgflags... no checking if the compiler supports __builtin_expect... yes checking if the compiler supports __builtin_ctzll... yes checking for zlibVersion in -lz... yes checking for lzo1x_1_15_compress in -llzo2... no checking for lzf_compress in -llzf... no checking for fastlz_compress in -lfastlz... no checking for qlz_compress in -lquicklz... no checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating snappy-stubs-public.h config.status: creating snappy.pc config.status: creating config.h config.status: executing depfiles commands config.status: executing libtool commands liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$
從以上輸出信息來看,沒有報錯信息,正常並經過。
接着執行安裝命令便可完成:
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ./configure --prefix=/Users/liuweiryan/opensource/env/snappy; make; make install
完成後,在 /Users/liuweiryan/opensource/env/snappy/lib 目錄下,會有以下文件:
liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$ ls ~/opensource/env/snappy/lib/ libsnappy.1.dylib libsnappy.dylib pkgconfig libsnappy.a libsnappy.la liuweideMacBook-Pro:snappy-1.1.4 liuweiryan$