Google protobuf in Linux - c++

I'm working with protobuf and Linux. Where is its compiler protoc? I've downloaded the package from the main site, compiled and installed it successfully but I can't find protoc to build my own format file. Where is it?
UPDATE
Here is folder where I built protobuf:
aclocal.m4 depcomp Makefile.in
autogen.sh editors missing
CHANGES.txt examples protobuf-lite.pc
config.guess generate_descriptor_proto.sh protobuf-lite.pc.in
config.h gtest protobuf.pc
config.h.in install-sh protobuf.pc.in
config.log INSTALL.txt python
config.status java README.txt
config.sub libtool src
configure ltmain.sh stamp-h1
configure.ac m4 vsprojects
CONTRIBUTORS.txt Makefile
COPYING.txt Makefile.am
There isn't a binary file I need.

It's probably installed into /usr/local/bin
On Ubuntu at least, you can apt-get install protobuf-compiler instead.
From the INSTALL.txt:
Installation Names
By default, 'make install' will install the package's files in
'/usr/local/bin', '/usr/local/man', etc. You can specify an
installation prefix other than '/usr/local' by giving 'configure' the
option '--prefix=PATH'.

First, you need to compile you source code from protobuff (in the root folder):
./configure
make
make check
make install
Second:
echo "/usr/local/lib">>/etc/ld.so.conf
echo "/usr/lib">>/etc/ld.so.conf
ldconfig
Third:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
Read README.txt in root folder for more info.

Also, if you are in fact on Ubuntu, then you can also fetch the source package from Debian unstable and rebuild them locally if you want packages that are more current than the last cutoff (which for Ubuntu 9.10 was some time late last summer). That way you end up with .deb packages and you preserve a normal upgrade path (rather than littering /usr/local with one-off installs).

You can find protoc in the path which you set ./configure --prefix=you_path.
When you make install successful, it will general bin, include and lib in that path.

Actually you don't need to know it's place.
All you want is to open terminal where your proto file is located and write at terminal
protoc -I=. --cpp_out=. filename.proto
follow this link for documentation

Related

Install eigen3.3.7 on MacOS

I am trying to build a program on MacOS and that program requires Eigen version <= 3.3.7 but mine has 3.3.8 with brew install eigen
I went to Eigen website but 3.3.7 source is no longer available anymore.
Any workaround?
Thanks a lot!
Updates: thanks a lot but I am still very confused with how to proceed. Below is the information of the installation details and directory info.
The directory of the program source code that I want to build look like:
program
cmake
Cmakelist.txt
build
the program has the following instructions:
Create the build directory in the source tree root
mkdir build
Configure cmake, from the build directory, passing the Shogun source root as an argument. It is recommended to use any of CMake GUIs (e.g. replace cmake .. with ccmake ..), in particular, if you feel unsure about possible parameters and configurations. Note that all cmake options read as -DOPTION=VALUE.
cd build
cmake [options] ..
Compile
make
Install (prepend sudo if installing system-wide), and you are done.
make install
Sometimes you might need to clean up your build (e.g. in case of some major changes). First, try
make clean
Then I have downloaded eigen3.3.7, where the INSTALL file is as following. How should I proceed?
Method 1. Installing without using CMake
****************************************
You can use right away the headers in the Eigen/ subdirectory. In order
to install, just copy this Eigen/ subdirectory to your favorite location.
If you also want the unsupported features, copy the unsupported/
subdirectory too.
Method 2. Installing using CMake
********************************
Let's call this directory 'source_dir' (where this INSTALL file is).
Before starting, create another directory which we will call 'build_dir'.
Do:
cd build_dir
cmake source_dir
make install
You can install Eigen 3.3.7 by compiling the source code(available here).

iwlib.h: No such file or directory

This is the first time for me to use Linux and its development tools. When I was trying to build the project I have to read, I had an error:
/home/charlie/AODV/llf.c:36: error: iwlib.h: No such file or directory
I was building the project with Qt. Beforehand, I installed libnl by make and make install, but the problem was not resolved. I am wondering if I did not install libel correctly or there are something more I have to do.
Welcome to Linux development.
You need to install libiw and it's development header(s).
How to do this is distribution dependant. On my Debian (should be more or less the same on any Debian based distro like Ubuntu):
jbm#sumo:~$ apt-cache search libiw
libiw-dev - Wireless tools - development files
libiw30 - Wireless tools - library
libiw30 is the binary lib, and the *-dev package is for it's header file(s), plus sometimes some docs (man pages etc). So:
jbm#sumo:~$ sudo apt-get install libiw-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
[...]
The following additional packages will be installed:
libiw30
The following NEW packages will be installed:
libiw-dev libiw30
Note how installing the header(s) for a lib rightfully install the library as well.
After install:
jbm#sumo:~$ find /usr/include/ -name iwlib.h
/usr/include/iwlib.h
jbm#sumo:~$ find /usr/lib -name "libiw*"
/usr/lib/x86_64-linux-gnu/libiw.so
/usr/lib/x86_64-linux-gnu/libiw.a
Note that:
/usr/include is part of the standard search path for headers of your
gcc toolchain, so you don't need to add a peculiar -I (for "include")
option.
/usr/lib is the same for lib binaries, so no need any -l or
-L (for "link") option.
You need to say to the compiler where to look for the header file. Use the -Idir option with dir the directory where the header file is.

How to install METIS on ubuntu

I want to install the METIS package on ubuntu.
I tried the instructions on the install.txt file which says to use
$ make install
which I did, after installing make as well.
I also tried the
sudo apt-get install metis
which installed it successfully but
when trying to use it in both cases I get
metis.h: No such file in directory compilation terminated
In case anyone asks I use g++ -I/path/to/file myprogram.cpp to specify the path where metis.h is.
I believe I haven't done something correct in the installation but I can't determine what it is.
Can someone help me with the installation process?
You can try sudo apt-get install libmetis-dev.
BUILD.txt file from metis:
Building METIS requires CMake 2.8, found at http://www.cmake.org/, as
well as GNU make. Assumming CMake and GNU make are installed, two
commands should suffice to build metis:
$ make config
$ make
so, i tried not directly on ubuntu, but on my mac and it works in that order.
after the two make command i have the following folder strucure:
build
-Darwin-x86_64 (the build architecture)
-libmetis
-libmetis.a
-programs
-gpmetis
...
after you can call
make install
I make a little test example and it works. You are maybe interest in my CMake-File. This could be the solution for your problem:
cmake_minimum_required(VERSION 2.8.9)
project (MetisTest)
include_directories("/usr/local/include")
link_directories("/usr/local/lib")
add_executable(metisTest main.cpp)
target_link_libraries(metisTest metis)
You may append your metis installation path to the environment variable CPLUS_INCLUDE_PATH. For example, in your ~/.bashrc, add:
export CPLUS_INCLUDE_PATH=$HOME/metis/include:$CPLUS_INCLUDE_PATH
then,
source ~/.bashrc
Please see more in the question Linux could not find metis.h.

How can I build libpoppler from source?

I just download poppler to Linux system,and I want to incorporate it in my app to parse pdf file.
(My goal is to convert pdf file to plain text.)
How can I do this?
Poppler's git tree includes a useless INSTALL doc that just tells you to run ./configure, but they don't include automake/autoconf auto-generated files (including configure) in git. (Probably they do include them in tarball source releases.)
I just built poppler from git source (on Ubuntu 15.04) like so:
git clone --depth 50 --no-single-branch git://git.freedesktop.org/git/poppler/poppler
cmake -G 'Unix Makefiles' # other -G options are to generate project files for various IDEs
# look at the output. If it didn't find some libraries,
# install them with your package manager and re-run cmake
make -j4
# optionally:
sudo make install
It appears that they maintain an autoconf/automake build setup, so you can use that OR cmake to create a Makefile.
If you just want to see if the latest git poppler works better than the distro package, you don't need to sudo make install, you can just run utils/pdftotext or whatever right from the source directory. It apparently tells the linker to embed the build path into the binary, as a library search path, so running /usr/local/src/poppler/utils/pdftotext works, and finds /usr/local/src/poppler/libpoppler.so.52.
If the latest poppler does work better than the distro-packaged poppler, you should install it to /usr/local/bin with sudo make install. When you upgrade to the next version of your distro, check your /usr/local. Often the new distro version will be newer than when you built it from source, so you should just remove your version from /usr/local/{bin,share,lib,man,include}. (Or make uninstall in the source dir, if supported).
Their website explains it very clearly :
Poppler is available from git. To clone the repository use the following command:
git clone git://git.freedesktop.org/git/poppler/poppler
Once you download the source code, read the INSTALL file where it says :
cd to the directory containing the package's source code and type
./configure to configure the package for your system.
Type `make' to compile the package.
Type `make install' to install the programs and any data files and
documentation.
Since some time has passed and it seems there was some uncertainty, I also took a look.
At the end of 2021, their homepage says
We run continuous integration via the gitlab CI
I checked out their .gitlab-ci.yml which has many build tasks. It would seem these days we build libpoppler like this:
git clone git://git.freedesktop.org/git/poppler/test test.repo
mkdir -p build && cd build
cmake -DTESTDATADIR=`pwd`/../test.repo -G Ninja ..
ninja

How to add compiler include paths and linker library paths for newly installed Boost?

I have RHEL 5.2, with Boost 1.33 installed.
I downloaded boost_1_44_0.tar.bz2. and built it. On completion it showed:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/dfe/Archive/boost_1_44_0
The following directory should be added to linker library paths:
/home/dfe/Archive/boost_1_44_0/stage/lib
How do I add the above mentioned include paths?
When I do "rpm -q boost", it shows boost-1.33.1-10.el5. Why is that so, when I've installed version 1.44?
Is there a better way to install the latest version of Boost?
There are always three steps to install software on Linux systems:
configure — "check"
make — "build software in current directory"
make install — "copy files to the systems so the other software can use this software"
You likely did the equivalent of make but did not do the equivalent of make install. You need to run
sudo ./b2 install
after running ./b2
Just add the paths to your .bashrc or .profile (or whatever floats your boat) like this:
export LIBS="-L/home/dfe/Archive/boost_1_44_0/stage/lib"
export CPPFLAGS="-I/home/dfe/Archive/boost_1_44_0"
You have to include these directories into makefile which you would use to build your application
CC -I/home/dfe/Archive/boost_1_44_0 -L/home/dfe/Archive/boost_1_44_0/stage/lib yourprogram.cpp
-I option Adds dir to the list of directories that are searched for #include files.
-L option adds dir to the list of directories searched for libraries by linker
CC is sun compiler...
First, I removed the existing boost rpm using
rpm -e boost-1.33.1-10.el5
A message is displayed saying "error: "boost" specifies multiple packages"
Then tried:
rpm -e --allmatches boost
(I don't remember whether I typed 'boost' or 'boost-1.33.1-10.el5')
The packages with dependencies were shown.
I did:
rpm -e [packagename1]
rpm -e [packagename2]
and so on and then did:
rpm -e --allmatches
This erased boost completely from my system.
Then I extracted boost_1_44_0.tar.bz2 using tar -xvjf boost_1_44_0.tar.bz2 and ran bootstrap with:
./bootstrap.sh
Then ran bjam as:
./bjam install
That's it! Boost got installed on my system, and I didn't have to specify any of the linker options while compiling programs! Yay!
Now the 'rpm -q boost' command shows that there is no package installed.