How can I build libpoppler from source? - c++

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

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).

Cmake question: How do I use vcpkg to install dependencies automatically?

I'm working on c++ project on a linux machine and it uses several boost libraries. I've installed them on my system using vcpkg and build it using the toolchain provided by vcpkg. My question is:
How do I define the dependencies so that they automatically install on a different system, if they were to build it?
Conan has a way of doing it by defining the dependencies in conanfile.txt. How do I do the same with vcpkg?
Edit1: I've found autovcpkg which does the job I'm looking to do but can the same be done natively inside cmakelists.txt or by vcpkg itself?
If you have vcpkg as a submodule for your project, define a manifest for the libraries you want vcpkg to build, and are using the vcpkg CMake toolchain - then you will get everything you want.
Adding vcpkg as a submodule means that your users don't need to install it themselves, the CMake toolchain will install it on your behalf. It also means that you can fix the package versions
Using a manifest file is how you programmatically tell vcpkg which packages to get and build during a CMake configuration phase
Using a CMake toolchain file is the only way to tie this into your project's build system
$ git clone .../my_project
$ cd ./my_project
$ git submodule update --init
$ mkdir ../build
$ cd ../build
$ cmake ../my_project
-- Running vcpkg install
-- Running vcpkg install - done
...
I've found autovcpkg which does the job I'm looking to do but can the same be done natively inside cmakelists.txt or by vcpkg itself?
You can write a vcpkg port for your library or executable by providing a CONTROL and portfile.cmake file. In the CONTROL file you define all the dependencies and possible features while the portfile contains the build instruction. You can use vcpkg create <myport> <url> <filename> to create the CONTROL and portfile.cmake from a template which can be customized to your needs.
Together with a port-overlay this port can also be used by others without being merged into vcpkg/master

Loris package installing issue

I'm trying to install Loris package link which is a library also for Python (my language). I have installed the package through bash commands in my OSX 10.12 system following these steps:
cd to the directory containing the package's source code and type
./configure to configure the package for your system. If you're
using csh on an old version of System V, you might need to type
sh ./configure instead to prevent csh from trying to execute
configure itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
Type `make' to compile the package.
Optionally, type `make check' to run any self-tests that come with
the package.
Type `make install' to install the programs and any data files and
documentation.
You can remove the program binaries and object files from the
source code directory by typing make clean. To also remove the
files that configure created (so you can compile the package for
a different kind of computer), type make distclean. There is
also a make maintainer-clean target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
The problem is that when I run both python 2.7 IDLE and the Atom editor it says that the module named Loris was not found. By default, make install will install the package's files in
/usr/local/bin,/usr/local/man.
Is this the problem? How can I install properly this library?

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.

Google protobuf in Linux

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