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

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

Related

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

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

Can not compile mlpack C++ program on Ubuntu

i downloaded mlpack and its dependencies from ubuntu repos as described in the docs using :
sudo apt-get install libmlpack-dev libmlpack-bin and then i ran :
pkg-config --cflags mlpack
And pkg-config --libs mlpack
And pkg-config --modversion mlpack
to make sure everything works and i got the expected outputs. Now in codeblocks i put the mlpack library directory in the search directory and the pkg-config --cflags mlpack in the compiler options, and the pkg-config --libs mlpack in the linker options. But when i build it gives me ld errors: libraries were not found. What frustrates me is that i have done the exact same procedure with other C++ libraries like OpenCV and it worked. So any help ? Does anyone managed to get it work before on linux ?
------Update------
I managed to fix it by only adding -lmlpack and -larmadillo to the linker options and not adding all --libs.

How to "include" libvlc and sdl1.2 on Raspbian C++ project?

I have installed "libsdl1.2-dev" and "libvlc" (with sudo apt-get install blah) in Raspbian on my Raspberry Pi, I'm using gcc to compile the example project from https://wiki.videolan.org/LibVLC_SampleCode_SDL/
This is my compile command:
gcc -fpermissive test.cpp -lvlc -lsdl1.2-dev -o test
It seems to compile (after I added -fpermissive and manually placed the vlc headers in usr/include/vlc) the error seems to happen during the linking phase, I get these 2 errors;
/usr/bin/ld: cannot find -lvlc
/usr/bin/ld: cannot find -lsdl1.2-dev
I'm a bit new to Linux and I can't work out why it can't find them. I'm also unsure where it installs them by default, there seem to be a few different places they could be.
Use pkg-config to get the needed compile and link flags. pkg-config --cflags sdl libvlc will print the needed compilation flags, and pkg-config --libs sdl libvlc the needed link flags. You can use the $() feature of the shell to embed the output of pkg-config directly into your compile command. Also, use g++ to compile and link C++ code. gcc is for C code.
g++ $(pkg-config --cflags sdl libvlc) -fpermissive test.cpp -o test $(pkg-config --libs sdl libvlc)
The package names sdl and libvlc correspond to *.pc files that are installed in /usr/lib/pkgconfig. If no such files exist, then that means you forgot to install the -dev versions of the sdl and vlc libraries. So check if there's a libvlc-dev package you need to install. Use this:
apt-cache search vlc | grep dev
See if there's a dev package for libvlc that you need.
To install libraries and header files, try sudo apt-get install libvlc-dev this should install all the dependent libraries in the correct library paths. sudo apt-get install vlc is used to install the application which in your case you dont need.
Try sudo apt-get install vlc, you're probably missing some plugins and stuff

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.

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