how to add pinocchio (a robotics package) as library in cmake - c++

I have to include pinocchio (an open-source library for robotics) in a c++ project via cmake, but it fails currently. (https://github.com/stack-of-tasks/pinocchio)
I've installed pinocchio c++ without the python bindings via
sudo apt install -qqy robotpkg-pinocchio
I've tried out the simple examples from the documentation https://gepettoweb.laas.fr/doc/stack-of-tasks/pinocchio/master/doxygen-html/index.html#OverviewComplex
If I compile it like this with the source code from the simplest example, it works:
g++ -std=c++11 overview-simple.cpp -o overview-simple $(pkg-config --cflags --libs pinocchio)
For including Pinocchio in a separate c++ project, I've tried the following things:
finding it as a package like this:
find_package(pinocchio 2.6.10)
but it fails with this message:
By not providing "FindPinocchio.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Pinocchio", but CMake did not find one.
Could not find a package configuration file provided by "Pinocchio"
(requested version 2.6.10) with any of the following names:
PinocchioConfig.cmake
pinocchio-config.cmake
Add the installation prefix of "Pinocchio" to CMAKE_PREFIX_PATH or set
"Pinocchio_DIR" to a directory containing one of the above files. If
"Pinocchio" provides a separate development package or SDK, be sure it has
been installed.
Can I somehow specify the path of the installed pinocchio library in the cmake file?
adding the compile options/flags just like in the example from the documentation
target_compile_options(${PROJECT_NAME} PUBLIC $(pkg-config --cflags --libs pinocchio))
but that also throws an error message. If it helps pkg-config --cflags --libs pinocchio, gives the following:
-DPINOCCHIO_WITH_URDFDOM -DPINOCCHIO_WITH_HPP_FCL -DHPP_FCL_HAS_OCTOMAP -DHPP_FCL_HAVE_OCTOMAP -DFCL_HAVE_OCTOMAP -DOCTOMAP_MAJOR_VERSION=1 -DOCTOMAP_MINOR_VERSION=9 -DOCTOMAP_PATCH_VERSION=7 -I/opt/openrobots/lib/pkgconfig/../../include -I/opt/openrobots/include -I/usr/local/include/eigen3 -I/usr/lib/x86_64-linux-gnu/pkgconfig/../../../include -L/opt/openrobots/lib/pkgconfig/../../lib -L/opt/openrobots/lib -L/usr/lib/x86_64-linux-gnu/pkgconfig/../../../lib/x86_64-linux-gnu -Wl,-rpath,/opt/openrobots/lib/pkgconfig/../../lib -lpinocchio -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lboost_filesystem -lboost_serialization -lboost_system -lurdfdom_sensor -lurdfdom_model_state -lurdfdom_model -lurdfdom_world -lconsole_bridge -Wl,-rpath,/opt/openrobots/lib -lhpp-fcl -loctomap -loctomath
Thank you very much!

From the pinocchio website pinocchio:
Configure environment variables
All the packages will be installed in the /opt/openrobots directory. To make use of installed libraries and programs, you must need to configure your PATH, PKG_CONFIG_PATH, PYTHONPATH and other similar environment variables to point inside this directory. For instance:
export PATH=/opt/openrobots/bin:$PATH
export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/opt/openrobots/lib/python2.7/site-packages:$PYTHONPATH # Adapt your desired python version here
export CMAKE_PREFIX_PATH=/opt/openrobots:$CMAKE_PREFIX_PATH
So try setting CMake environnement variable called CMAKE_PREFIX_PATH or use -D flag during cmake invocation:
cmake -D CMAKE_PREFIX_PATH=/usr/local/lib <path to source or build dir>
It specifies the path which will be used by the FIND command

Related

gtkmm: Simple example fails to compile: gtkmm.h: No such file or directory

I am working through the gtkmm documentation. I have started by trying to compile the "Simple Example". Here is the code. It can also be found here.
/// SimpleExample.cpp
#include <gtkmm.h>
int main(int argc, char *argv[])
{
auto app =
Gtk::Application::create(argc, argv,
"org.gtkmm.examples.base");
Gtk::Window window;
window.set_default_size(200, 200);
return app->run(window);
}
I have tried to compile this using
g++ SimpleExample.cpp -o SimpleExample `pkg-config gtkmm-3.0 --cflags --libs`
which should work according to the documentation. (See end of linked page.)
Running pkg-config gtkmm-3.0 --cflags --libs produces
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
I am running Debian 9 Stretch. I installed gtkmm with
sudo apt update && sudo apt install libgtkmm-3.0-dev
Running find /usr -name "gtkmm" produces
/usr/lib/x86_64-linux-gnu/pkgconfig/gtkmm-3.0.pc
/usr/lib/x86_64-linux-gnu/gtkmm-3.0
/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include/gtkmmconfig.h
/usr/include/gtkmm-3.0
/usr/include/gtkmm-3.0/gtkmm
/usr/include/gtkmm-3.0/gtkmm.h
So why does the example not compile?
Updates:
New terminal
pkg-config gtkmm-3.0 --cflags --libs
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
Try
find /usr -name "*gtkmm-3.0*"
/usr/lib/x86_64-linux-gnu/pkgconfig/gtkmm-3.0.pc
/usr/lib/x86_64-linux-gnu/libgtkmm-3.0.so.1.1.0
/usr/lib/x86_64-linux-gnu/libgtkmm-3.0.so.1
/usr/lib/x86_64-linux-gnu/gtkmm-3.0
/usr/lib/x86_64-linux-gnu/libgtkmm-3.0.so
/usr/share/doc/libgtkmm-3.0-1v5
/usr/share/doc/libgtkmm-3.0-dev
/usr/include/gtkmm-3.0
Export location
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig"
Re-run
pkg-config gtkmm-3.0 --cflags --libs
Package xproto was not found in the pkg-config search path.
Perhaps you should add the directory containing `xproto.pc'
to the PKG_CONFIG_PATH environment variable
Package 'xproto', required by 'xau', not found
(That's a different error this time.)
Try to find again
find /usr -name "*xproto*"
/usr/share/pkgconfig/xproto.pc
/usr/include/xcb/xproto.h
/usr/include/GL/glxproto.h
/usr/include/X11/extensions/lbxproto.h
Change export command
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig;/usr/share/pkgconfig"
Re-run, back to square 1
pkg-config gtkmm-3.0 --cflags --libs
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
Problem resolved (sort ot)
I have discovered from reading this question that the path should be colon seperated.
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig"
However this does not solve the problem of why this variable needs to be set at all. pkg-config is used because it is supposed to make compilation simpler, however this isn't any more simple than specifying the include paths manually, as multiple environment variables need to be set.
In addition, the lack of information about this issue online makes me suspect that this is an issue which most users do not encounter, and therefore is probably specific to Debian 9. (I would like to know if anyone else has encounted this problem, and on what OS.)
At first, it is normal that installing gtkmm is a bit complicated. As far as i can see, here in the Stackoverflow forum many users have problem with doing so. Even users in the Windows operating system are confronted with error messages, if they are trying to use gtkmm together with Visual Studio for developing a platform independent app ... But to your question. There are many options what can go wrong. A simple explanation would be, that the debian package “libgtk-3-dev” has to be installed, which is used for creating GTK+ apps in C, because gtkmm uses this package. So the first step is to try out, it the compilation of a C sourcecode for GTK+ works. A second explanation is, that the debian “package manager” is in general broken so switching the Linux distribution would be a good advice. For example, in Fedora a simple dnf install gtk3 gtk3-devel gtkmm30 gtkmm30-devel is enough for starting programming.

Missing "libiconv.h" when crosscompiling for Windows with mingw on Ubuntu

I have been working on a program in SDL and I would like to send it to my friends who only run a Windows environment. I have done some reading and found that I should use mingw to cross-compile for Windows. The binary I found and compiled was x86_64-w64-mingw32-g++, however I am getting some issues getting my program to compile. Using the following command I get the following error:
/usr/bin/x86_64-w64-mingw32-g++ sapphire.cpp `pkg-config --cflags --libs sdl2` -lSDL2_image -lSDL2_mixer -lSDL2_ttf -std=c++11
fatal error: iconv.h: No such file or directory
While I realize I should make a makefile eventually, I am not going to do that now.
I tried installing iconv (Version 1.15) from here and used the following commands to compile it:
./configure --prefix=/usr/local
make
make all
My iconv.h is located in /usr/include but if I include that I get another error for missing gnu/stubs.h and if I include that then I get a myriad of errors that I'm not sure how/if I could fix seen here. Does anyone know how I could perhaps fix this? I would appreciate any help!
Thanks in advance!
You can use pkg-config with mingw in a crosscompiler environment but you should take care to where pkg-config searches for his .pc files.
I'm assuming your mingw crosscompiler is installed in /usr/x86_64-w64-mingw32, change it to the installation path where his "include" and "lib" subdirectories are.
Provided SDL windows developement package is installed in the same prefix on your computer and the installation has a correct pkg-config .pc file you can do:
export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig
and then try pkg-config from the command line:
pkg-config sdl2 --cflags
This should point you to some path inside /usr/x86_64-w64-mingw32, if it does your compilation will be successful.
Please note that if you want to compile a package for crosscompile (like the iconv you tried to compile) you should add to the ./configure script parameters:
--host=x86_64-w64-mingw32 --prefix=/usr/xx86_64-w64-mingw32
... and this may work or not, depending the package support the mingw32 compiler or not.
The way you compiled iconv built another linux version of it in /usr/local!
NOTE: As far as I know Ubuntu does not provide a windows package for SDL2, while other linux distro do, so you'll need to cross-compile SDL2 with the option I gave before you can compile your code. SDL2 does support cross-compilation using mingw.

Can't use static lib of mongo-cxx-driver on Linux

So I follow the official tutorial for the installation : https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/
Neverless, I can't use the produced libraries as static.
So I managed to compile the C version of the driver as described, I've enabled the flag --enable-static=yes with the ./configure before doing make && sudo make install and I got the libmongoc-1.0.a and the libbson-1.0.a which are static. So this far, everything it's alright.
Then I have done the cxx version of the driver, except that there is no configuration file as in the C version. So I've juste done a
cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_BOOST=1 -DCMAKE_INSTALL_PREFIX=/usr/local
from the build folder, followed by a make && sudo make install
So I got the libmongocxx.a and the libbsoncxx.a, but when I try to compile with them, I can't run the binary because I got the following error :
error while loading shared libraries: libmongocxx.so._noabi: cannot open shared object file: No such file or directory
So I understand that is because there is some symbols missing and then I need to use the shared library to run the binary but I don't want this to happend, I want the symbols within the binary that I can run it without any LD_PRELOAD.
Any suggestions ?
I had the same issue in an Ubuntu 16.04 and I run a apt-get update & apt-get upgrade and the problem was solved.
It seems that there were some update to the compiler and some libraries that prevent some test from reaching the shared libraries.
I have a similar question, and solved, now I compiled and run my binary with static libs successfully.
I write my build script using newlisp, but the static link options are very helpful, I paste it here.
c++ /to/your/path/site/code/back_end/builder/object/files1.cc.o ... /to/your/path/site/code/back_end/builder/object/files10.cc.o -o bin/site -static-libgcc -static-libstdc++ -L/usr/lib -lpthread -l:libmongocxx.a -l:libbsoncxx.a -l:libmongoc-1.0.a -l:libbson-1.0.a -lrt -lssl -lcrypto -lsasl2 -l:libboost_log.a -l:libboost_log_setup.a -l:libboost_system.a -l:libboost_thread.a -l:libboost_filesystem.a -lcppcms -lbooster -lcurl -ljsoncpp

OS X - PKG_CONFIG_PATH results in empty pc_path, package not found

First off: I use OS X 10.10 Yosemite and I do everything from Terminal, no XCode IDE or other GUI involved. I installed pkg-config version 0.28 from Homebrew.
I want to build some software which depends on Ogre 1.8. I built and installed OGRE (via CMAKE_INSTALL_PREFIX) to a custom location in my home directory.
The layout is as follows:
~/install/bin contains binaries
~/install/include contains OGRE include headers
~/install/lib contains static libraries, e.g. libOgreMainStatic.a
~/install/lib/pkgconfig contains *.pc files for Ogre, e.g. OGRE.pc
Before I add the path to PKG_CONFIG_PATH I get this:
$ pkg-config --variable pc_path OGRE
Package OGRE was not found in the pkg-config search path.
Perhaps you should add the directory containing `OGRE.pc'
to the PKG_CONFIG_PATH environment variable
No package 'OGRE' found
This is expected behavior. I then added ~/install/lib/pkgconfig to my PKG_CONFIG_PATH like this:
$ export PKG_CONFIG_PATH=~/install/lib/pkgconfig
$ echo $PKG_CONFIG_PATH
/Users/myusername/install/lib/pkgconfig
Running
$ pkg-config --variable pc_path OGRE
<empty line while I expected the path to OGRE.pc>
again only shows an empty line but no error message however.
When I now run CMake for the software I want to build it says:
$ cmake .
<snip>
-- checking for module 'OGRE'
-- package 'OGRE' not found
What am I doing wrong? On Linux it works with the same commands.
The problem was that OGRE.pc referenced Freetype and a few other requirements which I had built from source. While Ogre was able to find them since they were in the path set by CMAKE_INSTALL_PREFIX pkgconfig wasn't because they didn't provide *.pc files.
I discovered this by using this command:
Before fix:
$ pkg-config --libs OGRE
Package zziplib was not found in the pkg-config search path.
Perhaps you should add the directory containing `zziplib.pc'
to the PKG_CONFIG_PATH environment variable
Package 'zziplib', required by 'OGRE', not found
After fix:
$ pkg-config --libs OGRE
-L/Users/myusername/install/lib -L/Users/myusername/install/lib/OGRE -lOgreMainStatic -lpthread -lboost-thread-mt -lfreeimage

A minimal way to install 'tesseract' for c++ development in linux?

According to this answer I would have to checkout entire repo of tesseract.
How do I install minimal packages of tesseract with c++ APIs for development and English language detection in linux (ubuntu)?
Update - Reason for using the large SVN repo is to enable g++ compilation.
When installed with apt-get:
bhp#Virtual-Machine:~/Desktop/bhp/opencv-tesseract$ pkg-config --cflags --libs tesseract
Package tesseract was not found in the pkg-config search path.
Perhaps you should add the directory containing `tesseract.pc'
to the PKG_CONFIG_PATH environment variable
No package 'tesseract' found
When built with source:
bhp#Virtual-Machine:~/Desktop/soft/tesseract-ocr$ pkg-config --cflags --libs tesseract
-I/usr/local/include/tesseract -L/usr/local/lib -ltesseract