Difference between libzmq and cppzmq , and between zmq.h and zmq.hpp? - c++

For installation of ZeroMQ on Linux-Ubuntu , one website
https://tuananh.org/2015/06/16/how-to-install-zeromq-on-ubuntu/
says to run following commands :
sudo apt-get install libtool pkg-config build-essential autoconf automake
sudo apt-get install libzmq-dev
in which we are installing libzmq-dev seperately.
Whereas according to
http://zeromq.org/intro:get-the-software
"Make sure that libtool, pkg-config, build-essential, autoconf, and automake are installed."
So we dont need to install libzmq-dev explicity.
So my question is what difference does it make? what is the use of libzmq? Is it different from libzmq-dev ? If I want to code in C++ , then do I need to install both libzmq and cppzmq ,as given in https://github.com/zeromq/cppzmq .
And please tell which header file( zmq.h ,zmq.hpp and zhelpers.hpp ) comes from which library?

libzmq contains the zmq library only (libzmq.so, libzmq.a).
libzmq-dev contains the library and also C header file (zmq.h). If you want to develop with zmq, you need to use this one instead of libzmq.
"Make sure that libtool, pkg-config, build-essential, autoconf, and automake are installed." So we dont need to install libzmq-dev explicity.
These tools are needed if you want to build libzmq from source code. No need to do that if you install via apt.
cppzmq is C++ binding for zmq so you can use C++ stuffs to work with ZMQ instead via C api that libzmq provide.
zmq.h from libzmq-dev, zmq.hpp and zhelpers.hpp from cppzmq.

Related

How to include jsoncpp library into project on unix?

The library I am trying to include is jsoncpp. I am having serious trouble with this. I used the home-brew install for this library, which is brew install jsoncpp (brew install is unix version of linux sudo-apt get). Normally homebrew installs stuff to my path, so I can just use it. I am going off of this example here.
#include <json/json.h>
Returns an error of 10: fatal error: 'json/value.h' file not found.
I am using cmake because CLion automatically sets it up. Right now it is very basic:
#CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(Read_JSON)
set(CMAKE_CXX_STANDARD 17)
add_executable(Read_JSON main.cpp)
However, for some reason jsoncpp cannot be found. How can I include this library in my project?
You can use in CMake FetchContent capability.
Jsoncpp is available via git repository on GitHub
Here is example how I made with googletest:
https://github.com/adamvm/hello/blob/master/CMakeLists.txt
You need just substitute proper addresses and names
On mac install with command.
brew install osrf/simulation/ignition-fuel-tools2
In Ubuntu (since 18.04) you need to install libjsoncpp-dev[1] package:
sudo apt install libjsoncpp-dev
[1] https://packages.ubuntu.com/search?keywords=libjsoncpp-dev

How to avoid users to manually install GDAL dependencies with CMake?

I know how to link GDAL with a C++ application using CMake. The procedure is summarized hereafter in two steps: (1) Installing the dependency on the system and (2) linking it to the C++ application (see here for more details).
Install GDAL (here on Ubuntu 18.04)
Add the PPA to the sources: sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
Update: sudo apt-get update
Install GDAL and its development files: sudo apt-get install gdal-bin libgdal-dev
Test the installation: gdalinfo --version
Link GDAL with the C++ application using CMake:
# find system installed GDAL package with predefined CMake variable for finding GDAL
find_package(GDAL REQUIRED)
...
# Specify location of GDAL header files
include_directories( include ${GDAL_INCLUDE_DIRS})
...
# Specify GDAL libraries to link your cpp executable target against
target_link_libraries( your_cpp_executable_target_name ${GDAL_LIBRARIES})
What is the most convenient way to avoid the user to perform the manual installation of the dependency? That is, how to ensure that the missing dependency will not stop the configuration, and download/build the dependency if not found on the system?
For managing the Boost dependency, I used the CMake ExternalProject feature with a Superbuild pattern, and I think a similar approach should be relevant for managing GDAL dependency. However, I am very new at modern CMake, and I struggle adapting this CMake project handling the Boost dependency to also manage a GDAL dependency.
Any general or step-by-step directions to help doing (or good reasons not to do so) would be helpful.

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.

install xmlrpc for c++ in /usr/local/lib

I want to use xml-rpc for C and C++ in a project. I was able to configure and make (build) the project correctly, however, i need the library to be installed in /usr/local/lib , /usr/local/include . When i run make install the library will be installed in /usr/lib , /usr/include.
Can anybody help, i.e. explain how to install the library in the other directory.
kind regards
you need to build it with : ./configure --prefix=/usr/local/ && make && make install.
Anyway, the best solution is probably to install it via the package manager of the distribution you are using.

why can't I to install boost in /usr/include?

I'm trying to install boost into include directory for avoid -I flag use in each g++ compiler call,I installed using this command line: ./bjam --prefix=/usr/include install
see --prefix value, it install in /home/myusername, why?
Thanks in advance.
You would need root permissions to install in /usr/include.
Actually your system has done you a favor by not letting you do that. The --prefix option says where to install everything -- headers, libraries, executables, documentation, etc. For example, the header files would be installed in /usr/include/include, which is not going to be in your compiler's search path.
Disclaimer:: This assume that ./bjam --prefix=... behaves similarly to ./configure --prefix=.... I haven't actually used bjam. If bjam's --prefix option means something else, please correct me.
Depending on your system, you may be able to install Boost from a repository rather than building it from source. For Debian or Ubuntu, for example, something like sudo apt-get install libboost might work.
Note that I said something like that; it appears that Boost consists of a number of packages; apt-cache search boost, or better yet, do a Google search to see how to install Boost on your particular system.
Try running
sudo ./bjam
Doing this should run bjam with appropriate privileges to install to /usr/local/include and /usr/local/lib, both of which should be in your search path...