C++ program requiring libsnappy - c++

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

Related

Linking problem to libraries installed with Homebrew since Mojave update

I have recently updated to Mojave and since then am experiencing linking problems to libraries (gsl, Cuba etc.) that I had installed with Homebrew.
When compiling my code, gcc (tried g++-6 and g++-8, also installed with brew) does not seem to search the directories where brew stores the header files for those libraries. The code compiled when I manually set the paths to
GSL_INCLUDE_PATH=/usr/local/include/gsl/
GSL_LIB_PATH=/usr/local/lib/
CUBA_PATH=/usr/local/include/
But since I am using this in all my make-files I do not want to do this every time...
Before I was using Sierra and I have included in my .bash_profile the following:
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
This seemed to do the trick before. But now /usr/local/sbin did not exist anymore. I ran brew doctor which suggested:
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/Frameworks /usr/local/sbin
sudo chown -R $(whoami) /usr/local/Frameworks /usr/local/sbin
I did just that and reinstalled the libraries but it did not sort out the issue.
I have tried to include
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/include:/usr/local/lib:$PATH
in the bash-profile, but that did not help either. (Maybe I did it wrong, I am not familiar with setting paths) At this point I am not sure whether brew installs the libraries in a weird place or if gcc just does not look in the correct location.
I have installed Xcode and the command tools. I have tried everything I found (and could understand) that I found as solutions for related problems.
I would like for gcc to look in the directories that brew installs the libraries to by default.
I would be really grateful for a suggestion of a clean fix for this issue.
Please excuse the long essay; if you need additional information please do tell, this ist my first time asking for help here.

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.

What does "/usr/lib/libstdc .so.6: version `GLIBCXX_3.4.15' not found" mean, and how do I fix it?

I'm new to compiling libraries .so under Ubuntu. I have the source, .cpp file. I installed the build-essentials package finely, and I'm using the Anjuta IDE to compile the source code. I have the Makefile and everything is good.
Now although it compiles without error, when I load it, I get the error:
/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found`
What does this mean and how can I fix it?
Edit: Any more tips?
Edit2: I really need help guys.
I had similar issues and I tried (https://askubuntu.com/questions/164296/glibcxx-3-4-15-not-found):
sudo apt-get install libstdc++6
optionally you can force a global update of all the linked libraries with
sudo ldconfig
this last command can take some time and will not print anything on the bash, just wait.
Sounds like a dependency problem, is your system up to date?
apt-get install && apt-get upgrade
One way to work around this issue is to simply link libstdc++ statically (with this parameter sent to g++ when linking the executable):
-static-libstdc++
If linking in the library statically is an option this is probably the quickest work-around.

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

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