Installing Google Protocol Buffers on mac - protocol-buffers

I would like to install the older version of Google Protocol Buffers (protobuf-2.4.1) on Mac using the command line/Terminal app.
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 the terminal?

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

This is not via brew, but the end result is the same.
Download the protobuf-2.4.1 from https://github.com/protocolbuffers/protobuf/releases/tag/v2.4.1
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.

If you landed here looking for how to install Protocol Buffers on Mac, it can be done using Homebrew by running the command below
brew install protobuf
It installs the latest version of protobuf available. For me, at the time of writing, this installed the v3.7.1
If you'd like to install an older version, please look up the available ones from the package page Protobuf Package - Homebrew and install that specific version of the package.
The oldest available protobuf version in this package is v3.6.1.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

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.

From https://github.com/paulirish/homebrew-versions-1 . Works for me!
brew install https://raw.githubusercontent.com/paulirish/homebrew-versions-1/master/protobuf241.rb

I used macports
sudo port install protobuf-cpp

To install Protocol Buffer (as of today version v3.7.0)
Go to this website
download the zip file according to your OS (e.g.: protoc-3.7.0-osx-x86_64.zip). This applies also to other OS.
Move the executable in protoc-3/bin/protoc to one of your directories in PATH. In Mac I suggest to put it into /usr/local/bin
Now your good to go 💪🏾
(optional) There is also an include file, you can add. This is a snippet of the README.md
If you intend to use the included well known types then don't forget to
copy the contents of the 'include' directory somewhere as well, for example
into '/usr/local/include/'.
Please refer to our official github site for more installation instructions:
https://github.com/protocolbuffers/protobuf

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

There is another official way by Google, as mentioned by another user.
Read it fully before trying.
Here are the steps:
Open Terminal and type the following
PROTOC_ZIP=protoc-3.7.1-osx-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
rm -f $PROTOC_ZIP
Worked for me.
P.S.
This is for version 3.7.1 in osx only.
If you want to install some other version/platform, visit the releases link and check out the details of the latest version, and use those information.
Reference

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.

HomeBrew versions has been removed and formulaes have been emptied. Therefore, my advice is to install it manually following the following steps.
For the time being you will need to build and install the Protocol Buffers toolset manually.
Download source code: https://github.com/google/protobuf/releases/download/v2.4.1/protobuf-2.4.1.tar.gz
tar xvfz protobuf-2.4.1.tar.gz
cd protobuf-2.4.1
Run ./configure
Edit src/google/protobuf/message.cc, add #include at the top of the file
Run make command from root of the folder, i.e. protobuf-2.4.1/
Run sudo make install
Run /usr/local/bin/protoc --version to check the version of protobuf compiler version
The terminal output should be:
Version: libprotoc 2.4.1

you can install from official link page provided by google http://google.github.io/proto-lens/installing-protoc.html

For v3 users.
http://google.github.io/proto-lens/installing-protoc.html
PROTOC_ZIP=protoc-3.7.1-osx-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP

There should be better ways but what I did today was:
Download from https://github.com/protocolbuffers/protobuf/releases (protoc-3.14.0-osx-x86_64.zip at this moment)
Unzip (double click the zip file)
Here, I added a symbolic link
ln -s ~/Downloads/protoc-3.14.0-osx-x86_64/bin/protoc /usr/local/bin/protoc
Check if works
protoc --version

Related

How to build goncurses on os x, centos 6

OS X, Centos 6 and Debian Squeeze all come with v5.7 of ncurses, but the go wrapper "goncurses" requires 5.9. Trying to build it on any of those platforms will give you an error like this:
$ go get -v code.google.com/p/goncurses
code.google.com/p/goncurses
# code.google.com/p/goncurses
/tmp/go-build527609801/code.google.com/p/goncurses/_obj/goncurses.o:
In function 'ncurses_is_subwin':src/code.google.com/p/goncurses/goncurses.c:71: undefined reference to `is_subwin'
/tmp/go-build527609801/code.google.com/p/goncurses/_obj/goncurses.o:
In function 'ncurses_is_pad':src/code.google.com/p/goncurses/goncurses.c:63: undefined reference to `is_pad'
You can use homebrew to install ncurses v5.9 on os x, and build from source into /usr/local/ on linux, but how do you get go to use your upgraded ncurses when building?
#JimB answered my other question How to change lib path for "go build" with a suggestion to leverage pkg-config, which solution will look like this:
On CentOS 6 you can build ncurses from source like this, which will put the .pc files that drive pkg-config into your own directory instead of /usr/lib64/pkgconfig/
mkdir ~/local-pkg-config
PKG_CONFIG_LIBDIR=~/local-pkg-config ./configure --prefix=/usr/local/ --enable-pc-files --with-pkg-config
make && make install
On OS X you can install ncurses from homebrew. Homebrew usually puts .pc files along with the package, e.g. /usr/local/Cellar/pango/1.34.1/lib/pkgconfig/pango.pc. For some reason homebrew doesn't have any .pc files with its ncurses, but I successfully grabbed the CentOS ones into ~/local-pkg-config and changed them to suit:
## -1,7 +1,7 ##
-prefix=/usr/local/
+prefix=/usr/local/Cellar/ncurses/5.9/
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
-includedir=${prefix}/include/ncurses
+includedir=${prefix}/include
major_version=5
version=5.9.20110404
Now on either platform you're set up to go get the goncurses package:
PKG_CONFIG_PATH=~/local-pkg-config/ go get -v code.google.com/p/goncurses
This Gist is a modified ncurses formula for Homebrew that adds the .pc files to the keg. If you install ncurses with it, use the PKG_CONFIG_PATH environment variable to point pkg-config to the .pc files, before calling go build or go run.
$ export PKG_CONFIG_PATH=/usr/local/Cellar/ncurses/5.9/lib/pkgconfig
$ go run your_ncurses_program.go

Error during RNNLib configuration: netcdfcpp.h cannot be found

When attempting to compile RNNLib, I got an error in NetcdfDataset.hpp:26:24 saying that Netcdfcpp.h could not be found. I looked around and found a bug report from 2011 that suggested that this was a bug, but it claimed to have been fixed. I have tried everything I can think of, including rebuilding NetCDF (a dependency of RNNLib) with various different flags, and have been unable to fix this bug. Can anyone give me a hand?
I had some trouble on a virtual machine building rnnlib.
I had to install the C and C++ version of NetCDF to get it to work.
The C version can be installed via sudo apt-get install libnetcdf-dev
I had to install the C++ version by building it.
Hope it will help. It's quite a difficult lib to install.
Maybe this helps someone: you can avoid some of the pain by installing packages from APT, and access the correct version mentioned by user3620756, which contains the netcdfcpp.h header file
. This happens through a legacy package, available on Ubuntun 16.04 (Xenial universe, see APT repository).
First install libnetcdf for C, then install libnetcdf-cxx-legacy-dev which should depend on libnetcdf-c++4 and install required C++ libraries on the go:
sudo apt install libnetcdf-dev libnetcdf-cxx-legacy-dev
The newest version doesn't have this netcdfcpp.h file anymore.
I had to use ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz to get it working.
I have also followed the same process and it worked for me
"The newest version doesn't have this netcdfcpp.h file anymore. I had to use ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz to get it working."
After downloading the folder, I had to build it by entering into the netcdf folder. I used simple command for the task :
.\configure
make
sudo make install
But in the file named as "NetcdfDataset.hpp", I have to give the complete path of the netcdfcpp.h file. For my case the path of the include file is :
#include "/Volumes/Macintosh_HD_2/WordSpottingProj/trunk/CODE C++/rnnlib_source_forge_version/netcdf-cxx-4.2/cxx/netcdfcpp.h"
I had this problem in the context of trying to use a makefile that called for netcdfcpp.h:
$ make -f makefile_MAC
c++ -O2 -o burn7.x burn7.cpp -I/opt/local/include -L/opt/local/lib -lm -lnetcdf_c++
burn7.cpp:31:10: fatal error: 'netcdfcpp.h' file not found
#include <netcdfcpp.h>
^
1 error generated.
make: *** [burn7.x] Error 1
I'm on a Mac, so I used Homewbrew to install the NetCDF package, but version 4.3.3.1 didn't appear to have netcdfcpp.h:
brew install homebrew/science/netcdf
However, I found that installing it with an additional flag resulted in this version being included:
brew install homebrew/science/netcdf --with-cxx-compat
I assume that the same is true of other installation/compilation methods, and not that this file has been taken out of versions since 4.2 as others answers state. Maybe it was a default option before and now it isn't?

Install previous version of a package from old source in windows [duplicate]

A friend sent me along this great tutorial on webscraping The New York Times with R. I would really love to try it. However, the first step is to install a package called [RJSONIO][2] from source.
I know R reasonably well, but I have no idea how to install a package from source.
I'm running macOS (OS X).
If you have the file locally, then use install.packages() and set the repos=NULL:
install.packages(path_to_file, repos = NULL, type="source")
Where path_to_file would represent the full path and file name:
On Windows it will look something like this: "C:\\RJSONIO_0.2-3.tar.gz".
On UNIX it will look like this: "/home/blah/RJSONIO_0.2-3.tar.gz".
Download the source package, open Terminal.app, navigate to the directory where you currently have the file, and then execute:
R CMD INSTALL RJSONIO_0.2-3.tar.gz
Do note that this will only succeed when either: a) the package does not need compilation or b) the needed system tools for compilation are present. See: R for Mac OS X
You can install directly from the repository (note the type="source"):
install.packages("RJSONIO", repos = "http://www.omegahat.org/R", type="source")
A supplementarily handy (but trivial) tip for installing older version of packages from source.
First, if you call "install.packages", it always installs the latest package from repo. If you want to install the older version of packages, say for compatibility, you can call install.packages("url_to_source", repo=NULL, type="source"). For example:
install.packages("http://cran.r-project.org/src/contrib/Archive/RNetLogo/RNetLogo_0.9-6.tar.gz", repo=NULL, type="source")
Without manually downloading packages to the local disk and switching to the command line or installing from local disk, I found it is very convenient and simplify the call (one-step).
Plus: you can use this trick with devtools library's dev_mode, in order to manage different versions of packages:
Reference: doc devtools
From CRAN, you can install directly from a GitHub repository address. So if you want the package at https://github.com/twitter/AnomalyDetection, using
library(devtools)
install_github("twitter/AnomalyDetection")
does the trick.
In addition, you can build the binary package using the --binary option.
R CMD build --binary RJSONIO_0.2-3.tar.gz
If you have source code you wrote yourself, downloaded (cloned) from GitHub, or otherwise copied or moved to your computer from some other source, a nice simple way to install the package/library is:
In R
It's as simple as:
# install.packages("devtools")
devtools::install('path/to/package')
From terminal
From here, you can clone a GitHub repo and install it with:
git clone https://github.com/user/repo.git
R -e "install.packages('devtools');devtools::install('path/to/package')"
Or if you already have devtools installed, you can skip that first bit and just clone the repo and run:
R -e "devtools::install('path/to/package')"
Note that if you're on ubuntu, install these system libraries before installing devtools (or devtools won't install properly).
apt-get update
apt-get install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev libfontconfig1-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev -y

Include boost in xcode

I could not include boost in xcode.
I used the build instructions from the Boost documentation and wrote the search paths in xcode /usr/local/lib and /usr/local/include.
Any help please !
I have spent a long time trying to make this work. I could not make it work using the download from the Boost project homepage, so I used homebrew instead:
After homebrew is installed, I installed Boost using:
brew install boost
or, if you don't have python installed, using:
brew install boost --without-python
Without the --without-python it would not install on my machine.
In XCode (4.3.3), select the project file in the left sidebar (top most), and select it again in the project pane.
Select the Build Settings tab, and select All.
Under Search Paths, add the header search path /usr/local/Cellar/boost/1.49.0/include/ and check the box. The path should now show in the Build Settings.
Now, you can use:
#include <boost/regex.hpp>
or whatever you need from the Boost package.
In case you have boost already installed, use $ brew info boost to get the correct path:
boost: stable 1.60.0 (bottled), HEAD
Collection of portable C++ source libraries
https://www.boost.org/
/usr/local/Cellar/boost/1.60.0_1 (11,139 files, 436.5M) *
Poured from bottle
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/boost.rb
I followed henrikstroem's great post, like this:
Install via homebrew, took less than 3 minutes
mac:~ woz$ brew install boost
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/boost-1.57.0.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring boost-1.57.0.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/boost/1.57.0: 10572 files, 439M
mac:~ woz$
Create symlink in your homedir
mac:~ woz$ cd
mac:~ woz$ ln -s /usr/local/Cellar/boost/1.57.0 boost_1_57_0
mac:~ woz$
Inside Xcode refer to the just created symlink like this
For the Header Search Paths use $(HOME)/boost_1_57_0/include
For the Library Search Paths use $(HOME)/boost_1_57_0/lib
I'm using boost with Xcode 3.2.1 on mac os 10.6.8
I had problems with using boost and Xcode today, finally I managed to make it work so I hope this helps:
download boost, I got the 1.52.0 today, untar it
install boost:
at first I couldn't do the ./bootstrap.sh, it stopped after the first few lines. After some googling, I got the answer, it was because when I installed Xcode a long time ago, for some reason I didn't check the “Unix development" in the install options. At this point, reinstall a newer version of Xcode and check the "unix development line"
after that, the ./bootstrap and ./b2 install worked fine
the lambda example:
at this point, the first example should work fine, if it doesn't try adding /usr/local/include in the project settings/header search path
using thread or something else that requires to be built
threads require a specific dylib to work: libboost_system.dylib. on my system it was located in /usr/local/lib after the ./b2 install thingy
in the left part of the GUI, you can right click anywhere and select Add Existing File
if the file is hidden you can find a shortcut to get to usr/local/lib in the directory /Developer/SDKs/MacOSX10.6.sdk/usr/local
once the libboost_system.dylib does appear in the Groups and Files part of the GUI, it should work
mic#mbp: ~/work $ brew install boost
mic#mbp: ~/work $ ls -l /usr/local/include/boost
lrwxr-xr-x 1 mic wheel 36 Nov 27 01:06 /usr/local/include/boost -> ../Cellar/boost/1.56.0/include/boost
hi, I add /usr/local/include in Header Search Paths (with double click it, but Debug or other sub checks), then
#include <boost/asio.hpp>
#include <boost/date_time.hpp>
using namespace boost;
int main() {
asio::io_service io;
io.run();
return 0;
}
worked, :D

Installing GCC on Oracle Solaris 11

i recently got Oracle Solaris on my VM to test some code on it, i was unable to install gcc since i dont really know how, i googled alot but all info is about oracle compilers, i needed GCC, any idea where can i get GCC or how to install it?
thanks
The original answer applied to Solaris 11 Express/non-official release - if you're doing this today with a full release of Solaris 11.x, use the pkg install command like you see in xavier's response.
Run this command from your terminal to install GCC.
For GCC 3.4.x
pkg install gcc-3
For GCC 4.5.x
pkg install gcc-45
For GCC 4.7.x
pkg install gcc-47
For GCC 4.8.x
pkg install gcc-48
The gcc command should then already be placed in your path /usr/bin/gcc, which is a symlink).
Old Answer
Solaris 11 should already have gcc installed in /usr/sfw/bin/, but it's probably not in your PATH. Try this at the prompt: /usr/sfw/bin/gcc
Two steps:
pkg install gcc-45
pkg install system/header
that is all
if you see more info
http://blog.csdn.net/zjg555543/article/details/8217769
Just download gcc from its homepage, follow one of the mirror links to fetch the latest binary package (in .tar.gz or tar.bz2 format), and use traditional steps to build:
./configure --<> // give your options
make
make install
The good news is you can customize what you need and always stay with the latest, while bad part is you may lose the power to debug with mdb/adb - we are facing such problems with latest GCC 4.6.x
Solaris 10 and prior version :
/usr/sfw/bin/gcc works.
Solaris 11 :
pkg install gcc-3
pkg install gcc
worked for me
This will install entire gcc collection on your machine. Which anyways will be required
My Solaris 2.11 does NOT have internet access :/
What work for me:
(1) I use this link as guideline
(2) From my windows machine, download gcc at one of their mirror sites, i used here, normally the closer the better
(3) Upload gcc-9.2.0.tar.gz to target /tmp directory using WinSCP
(4) tar -xvf gcc-9.2.0.tar.gz
(5) cd gcc-9.2.0
(6) mkdir /usr/local/gcc
(7) cd /usr/local/gcc
(8) /tmp/gcc-9.2.0/configure -v --program-suffix=9.2
At this point, you might get this error:
Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
(9) Manually download the required files here.
Note: To know what files are required, check contrib/download_prerequisites
(10)Copy over the files in (9) to /tmp/gcc-9.2.0
(11)Extract, then create shortcuts: ln -s gmp-6.1.0 gmp, ln -s mpc-1.0.3 mpc, ln -s mpfr-3.1.4 mpfr, ln -s isl-0.18 isl
(12)/tmp/gcc-9.2.0/configure -v --program-suffix=9.2 --enable-languages=c,c++ -v
(13) nohup gmake & (At this point it's going to take some time...mine took ~6 hours. Use -j option if you can, to gmake it faster )
(14) gmake install
(15) /usr/local/bin# ./gcc9.2 --version
gcc9.2 (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
Voila! :-)
You can install gcc 4.3 from OpenCSW:
pkg-get -i gcc4code gcc4g++
I also had to run mkheaders manually after the install.
I had the same problem and 'pkg install gcc-3' worked for me.
I'll quote the answer from unix.stackexchange.com.
On Solaris 11 gcc is not installed by default. Normally you'll want more than just the compiler itself so my answer will include all the usual suspects for building open source software on Solaris that you've downloaded from somewhere in source code format.
By far the easiest is to use IPS to install it using the commands below (while being root or other superuser):
pkg install pkg://solaris/developer/build/gnu-make \
pkg://solaris/developer/build/make \
pkg://solaris/developer/gcc \
pkg://solaris/system/header \
pkg://solaris/developer/build/autoconf \
pkg://solaris/developer/build/automake
(I use fully qualified package names here, that is not really necessary)
Note that some of the packages are available in the official repo in various versions. If you just reference developer/gcc then you'll at the time of writing this get GNU C v4.8.2, but you may explicitly ask for a prior version, e.g. by using package name such as developer/gcc-45.

Resources