可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I would like to install the older version of Google Protocol Buffers (protobuf-2.4.1) on mac using Terminal command line. I tried with brew install protobuf
, but the latest version 2.5.0 has been installed. Is it possible to install the older version from terminal.
Thanks
回答1:
There are some issues with building protobuf 2.4.1 from source on a Mac. There is a patch that also has to be applied. All this is contained within the homebrew protobuf241 formula, so I would advise using it.
To install protocol buffer version 2.4.1 type the following into a terminal:
brew tap homebrew/versions brew install protobuf241
If you already have a protocol buffer version that you tried to install from source, you can type the following into a terminal to have the source code overwritten by the homebrew version:
brew link --force --overwrite protobuf241
Check that you now have the correct version installed by typing:
protoc --version
It should display 2.4.1
回答2:
This is not via brew, but the end result is the same.
- Download the protobuf-2.4.1 from https://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
- Extract the tar.gz file.
- $cd ~/Downloads/protobuf-2.4.1
- $./configure
- $make
- $make check
- $sudo make install
- $which protoc
- $protoc --version
Steps 4-7 are from the README.txt file from the protobuf tarball.
回答3:
It's a new year and there's a new mismatch between the version of protobuf
in Homebrew and the cutting edge release. As of February 2016, brew install protobuf
will give you version 2.6.1.
If you want the 3.0 beta release instead, you can install it with:
brew install --devel protobuf
回答4:
For some reason I need to use protobuf 2.4.1 in my project on OS X El Capitan. However homebrew has removed protobuf241 from its formula. I install it according @kksensei's answer manually and have to fix some error during the process.
During the make process, I get 3 error like following:
google/protobuf/message.cc:130:60: error: implicit instantiation of undefined template 'std::__1::basic_istream<char, std::__1::char_traits<char> >' return ParseFromZeroCopyStream(&zero_copy_input) && input->eof(); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:108:28: note: template is declared here class _LIBCPP_TYPE_VIS basic_istream; ^ google/protobuf/message.cc:135:67: error: implicit instantiation of undefined template 'std::__1::basic_istream<char, std::__1::char_traits<char> >' return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof(); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:108:28: note: template is declared here class _LIBCPP_TYPE_VIS basic_istream; ^ google/protobuf/message.cc:175:16: error: implicit instantiation of undefined template 'std::__1::basic_ostream<char, std::__1::char_traits<char> >' return output->good(); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:110:28: note: template is declared here class _LIBCPP_TYPE_VIS basic_ostream; ^
(Sorry, I dont know how to attach code when the code contains '`' )
If you get the same error, please edit src/google/protobuf/message.cc, add #include <istream>
at the top of the file and do $ make
again and should get no errors. After that do $ sudo make install
. When install finished $protoc --version
should display the correct result.
回答5:
From https://github.com/paulirish/homebrew-versions-1 . Works for me!
brew install https://raw.githubusercontent.com/paulirish/homebrew-versions-1/master/protobuf241.rb
回答6:
I used macports
sudo port install protobuf-cpp
回答7:
brew install --devel protobuf
If it tells you "protobuf-2.6.1 already installed": 1. brew uninstall --devel protobuf
2. brew link libtool
3. brew install --devel protobuf
回答8:
FWIW., the latest version of brew is at protobuf 3.0, and doesn't include any formulae for the older versions. This is somewhat "inconvenient".
While protobuf may be compatible at the wire level, it is absolutely not compatible at the level of generated java classes: you can't use .class files generated with protoc 2.4 with the protobuf-2.5 JAR, etc. etc. This is why updating protobuf versions is such a sensitive topic in the Hadoop stack: it invariably requires coordination across different projects, and is traumatic enough that nobody likes to do it.