How to install METIS on ubuntu - c++

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.

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

C++ program requiring libsnappy

I am trying to make and build a C++ program (available here https://github.com/mortehu/text-classifier) which requires libsnappy and Capn Proto. I believe I am having an issue with libsnappy as after running the following commands:
configure
make -L/Users/liamflynn/Desktop/Kaggle/Truly_Native/Mortehu/text-classifier-master/tools/text-classifier/capnproto-c++-0.5.3/src
sudo make install
I get the error "base/columnfile.cc:7:10: fatal error: 'snappy.h' file not found"
I have tried linking various folders related to libsnappy in the make stage to no avail. I have also tried to install snappy in a few different ways, such as:
brew install snappy
and
sudo gem install libsnappy
But Im not exactly sure where the library is getting saved too. Ideally, I would be able to find the folder containing 'snappy.h' and I would be able to link this in the make stage. Any help with where I am going wrong would be much appreciated, thank you.
The headers are read by the preprocessor. You can add preprocessor command line flags by changing the CPPFLAGS variable. Use the LDFLAGS variable for linker flags:
./configure CPPFLAGS="-I/path/to/header/" LDFLAGS="-L/path/to/library/"
Since you tagged homebrew I'm assuming that you're on MacOS and have brew installed. With this you can run the following command to install the libsnappy library:
$ brew install snappy

Python.h: No such file or directory

I recently installed KDevelop 4 for C++ development on my Macbook Pro running Ubuntu 12.04 LTS.
I want to embed Python application in my C++ code. To do that, one needs to include the Python.h header file. So, I did that.
#include <iostream>
#include <Python.h>
int main(int argc, char **argv) {
Py_Initialize();
return 0;
}
However, on running, I received the following response from the IDE:
fatal error: Python.h: No such file or directory
However, I found the problem soon enough. I hadn't downloaded the python-dev package. So, I did that. I ran again but the same error was there again. So, I thought it must be an issue with the header file not being included by KDevelop. Thus, I added the relevant folder to the include path and KDevelop immediately recognized that by removing the red underline beneath the second include statement in the code above.
But still, the problem remains. I get the same error. Would appreciate any help or inputs you guys can provide :-)
Thanks a lot.
EDIT: Some details that I missed mentioning earlier are that KDevelop is using cmake for my project. I guess the reason my problem is occurring is because cmake doesn't know the appropriate compiler and linker paths. I would appreciate any help in setting the correct paths for cmake.
In your CMakeLists.txt, try adding the following:
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
target_link_libraries(<your exe or lib> ${PYTHON_LIBRARIES})
For details of the commands, run:
cmake --help-module FindPythonLibs
cmake --help-command find_package
cmake --help-command include_directories
cmake --help-command target_link_libraries
sudo apt-get install pythonX.X-dev
For example for 3.8
sudo apt-get install python3.8-dev
Thank you Cristianjs19 for the comment.
Original Answer:
sudo apt-get install python2.7-dev
worked for me on a "Python.h: No such file or directory" issue
You want to include the following on the compile line:
`python-config --cflags`
and this on the link line:
`python-config --ldflags`
Most likely Python.h is not in your build systems' include path. You can find out where your Python.h is by running
dpkg -L python-dev | grep Python.h
This will also verify that the python-dev package actually installed a Python.h.
I don't have a kdevelop here, but most IDEs have a setting somewhere where you can specify the include path used by the build system, and you should be able to add the path where Python.h lies there.
EDIT:
As Nikolai implied, you will also need to add the correct library path for the linking stage. (Output of python-config --ldflags).
For Linux Ubuntu Putty Users try this:
sudo apt-get update
sudo apt-get install python-dev
then compile it
gcc -o check xyz.c -I/usr/include/python2.7/ -lpython2.7
then run it
./check
I assume that it is already installed. Find the path with:
find / -iname python.h
and when you have done so, when compiling add
-I python_h_path

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

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