mongo.h: No such file or directory - mongodb

I get the mongo-c-driver from official website, as follows:
$git https://github.com/mongodb/mongo-c-driver.git
$cd mongo-c-driver
$./autogen.sh
$ make
$ sudo make install
Deal.c:2:19: fatal error: mongo.h: No such file or directory
However,when I run my C file named "Deal.c" like this:
gcc -o Deal Deal.c -l /usr/local/include -L /usr/local/lib -lmongoc
Error:#include "mongo.h"
^ compilation terminated.
My system version: is Ubuntu 13.10

It appears that you are missing the path to the headers as well as the locations of the libraries. One option would be to install to the same prefix that your platform uses, such as:
./configure --prefix=/usr --libdir=/usr/lib64
If that is not an option, then you can update your Makefile to include the proper library and include path as such:
gcc Deal.c -L/usr/local/lib -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -lmongoc-1.0 -lbson-1.0
This will typically be done automatically for you by using pkg-config on Unix'like systems as such:
gcc Deal.c $(pkg-config --cflags --libs libmongoc-1.0)
However, if you install into a non-standard path such as /usr/local, then you will need to let pkg-config know where to find the libmongoc-1.0.pc file, such as:
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gcc Deal.c $(pkg-config --cflags --libs libmongoc-1.0)

Related

sslscan.c:94:25: fatal error: openssl/err.h: No such file or directory compilation terminated. #163

I am need to install sslscan tool for ssl scanning (from here) in ubuntu virtual machine (virtualbox).
Following their installation instructions provided here, I installed openssl-chacha from here. Note that I am aware that this fork of openssl contains weak cipehrs (I use the tool and openssl for testing-scanning purposes not real application).
Then, after installing the above openssl, the first thing I did is executing: make. Note that it is unclear to me when to use these commands that he sslscan mentioned here (I did not execute them). But I want to use the chacha version of openssl:
apt-get install build-essential git zlib1g-dev
apt-get build-dep openssl
make static
When I try to run the command: make I get this error:
make: git: Command not found
cc -o sslscan -Wall -Wformat=2 -Wformat-security -pie -z relro -z now -L/usr/local/lib -L/usr/local/ssl/lib -L/usr/local/opt/openssl/lib -L/opt/local/lib -D_FORTIFY_SOURCE=2 -fstack-protector-all -fPIE -I/usr/local/include -I/usr/local/ssl/include -I/usr/local/ssl/include/openssl -I/usr/local/opt/openssl/include -I/opt/local/include -I/opt/local/include/openssl -DVERSION=\"1.11.11\" sslscan.c -lssl -lcrypto -ldl
/usr/bin/ld: /usr/local/ssl/lib/libssl.a(s2_clnt.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libssl.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:91: recipe for target 'sslscan' failed
make: *** [sslscan] Error 1
I am in this directory: /home/myuser/Downloads/sslscan-master
I made sure that openssl in:
/usr/local/ssl
Can you please point to me what is missing? I am not familiar with Linux system (Windows user) but I prefer to use the tool in Linux. So I will appreciate your help and patience.
make: git: Command not found
So start by installing the git command:
apt-get install git
(or maybe git-core)

cpanm use custom libs and cflags

On my mac OS X machine Darwin maci 15.6.0 Darwin Kernel Version 15.6.0
I have installed libxml2 and libxslt in following custom directory
/usr/local/MyLibs/libxml2-2.9.2
and libxslt
/usr/local/MyLibs/libxslt-1.1.29
Now I want to use these libs to build my CPANM module XML::LibXSLT.
This tells me that I can do so using --configure-args (its still experimental). So I do something like,
cpanm http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF/XML-LibXSLT-1.94.tar.gz --configure-args="--cflags=-I/usr/local/libxslt-1.1.29/include -I/usr/include/libxml2 -I/usr/local/MyLibs/libxml2-2.9.2/include/libxml2 --libs=-L/usr/local/libxslt-1.1.29/lib -lxslt -lxml2 -lz -lpthread -licucore -lm -L/usr/local/MyLibs/libxml2-2.9.2/lib -lxml2 -lz -lpthread -liconv -lm" --force
However, the build log says that it did not use the libraries installed in my custom location.
Is there something that I am not doing correctly?
From the distro's README,
The Makefile.PL tries to determine the correct compiler and linker
flags for its library dependencies using pkg-config and
xslt-config. If this fails, you may override the values like this
perl Makefile.PL INC="..." LIBS="..."
where INC contains flags for the compiler (such as -I/some_path/include etc.) and LIBS contains linker flags (such as -L/some_path/lib -llibsomething ...).
It might be simpler to forgo cpanm and install the module yourself.
curl -L -o - http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF/XML-LibXSLT-1.95.tar.gz | tar xz
cd XML-LibXSLT-1.95
perl Makefile.PL INC="..." LIBS="..."
make test
make install
I think you were missing quotes around the --cflags argument (needed in order to group multiple space-separated arguments together):
--configure-args="--cflags='-I/usr/local/libxslt-1.1.29/include -I/usr/include/libxml2 -I/usr/local/MyLibs/libxml2-2.9.2/include/libxml2'"
However --cflags and --libs are just examples from the cpanm documentation, and might not even be recognized by a distribution's Makefile.PL. As the other answer points out, the arguments to use for XML::LibXSLT are INC="…" and LIBS="…"; I think providing those to cpanm's --configure-args should work:
cpanm --configure-args="INC='…' LIBS='…'"

Emacs 25.1 on lubuntu 16.04 won't configure due to missing libpng

I am attempting to install emacs 25.1 on lubuntu 16.04, and having some trouble. After downloading and extracting the tar, I navigate to the emacs 25.1 directory then..
./configure
The configuration stops when I receive the message
configure: error: The following required libraries were not found:
libpng
Maybe some development libraries/packages are missing?
If you don't want to link with them give
--with-png=no
as options to configure
When I try sudo apt install libpng-dev
I get the message
Note, selecting 'libpng12-dev' instead of 'libpng-dev'
libpng12-dev is already the newest version (1.2.54-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
I tried reinstalling libpng12-dev using the below string, which didn't help at all.
sudo apt-get install --reinstall libpng12-0=1.2.54-1ubuntu1
I'm stuck here, I've googled around for a while and can't find any solutions that have actually worked.
I have the same problem. After I checked the config.log file, I found out that because I already installed Anaconda3 python
when gcc compile emacs it uses some libpng... found in Anconda3 directory.
So I remove related Anaconda3 directory in PATH, everything turns out right.
The wrong version:
configure:15301: result: -lz
configure:15407: checking for png
configure:15437: gcc -o conftest -g3 -O2 -I/etc/anaconda3/include/libpng16 conftest.c -lpng16 -lz -lm -lX11 >&5
/usr/bin/ld: cannot find -lpng16
The right version:
configure:15301: result: -lz
configure:15407: checking for png
configure:15437: gcc -o conftest -g3 -O2 -I/usr/include/libpng12 conftest.c -lpng12 -lz -lm -lX11 >&5
configure:15437: $? = 0
configure:15452: result: yes
Hope that would be helpful!
The solution is to remove the default version of libpng-dev (1.2) and explicitly install version 1.6: sudo apt-get remove libpng-dev && sudo apt-get install libpng16-dev
Explicit versions of dependencies don't seem to be documented in the readme files.

Installing Bio::DB::Sam perl module

I am trying to install a perl module Bio::DB::Sam on my home directory on a remote server.
I downloaded the module, extracted the files, and ran:
perl Build.pl prefix=~/local
this is what happens next:
This module requires samtools 0.1.10 or higher (samtools.sourceforge.net).
Please enter the location of the bam.h and compiled libbam.a files: **/some_places/samtools-0.1.19**
Found /some_places/samtools-0.1.19/bam.h and /some_places/samtools-0.1.19/libbam.a.
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Bio-SamTools' version '1.39'
Next when I try to run:
./Build
this is what I get:
Building Bio-SamTools
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -o blib/arch/auto/Bio/DB/Sam/Sam.so lib/Bio/DB/Sam.o c_bin/bam2bedgraph.o -L/some_places/samtools-0.1.19 -lbam -lpthread -lz
/usr/bin/ld: /some_places/samtools-0.1.19/libbam.a(bgzf.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/some_places/samtools-0.1.19/libbam.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error building blib/arch/auto/Bio/DB/Sam/Sam.so from lib/Bio/DB/Sam.o c_bin/bam2bedgraph.o at ~/perl5/lib/perl5/ExtUtils/CBuilder/Base.pm line 323.
I did google the possible solutions and tried a couple, but they didn't work, e.g. --enable-shared OR export CXXFLAGS="$CXXFLAGS -fPIC".
I have already have Bioperl installed on my home directory.
Any help would be appreciated.
Cheers
Here is a script that will fetch the SAMtools source and compile it, then fetch and compile the Perl bindings.
wget http://sourceforge.net/projects/samtools/files/samtools/0.1.18/samtools-0.1.18.tar.bz2
tar xjf samtools-0.1.18.tar.bz2 && cd samtools-0.1.18
make CFLAGS=-fPIC
export SAMTOOLS=`pwd`
cpanm Bio::DB::Sam
Part of the problem you were likely seeing is that the SAMtools project has recently undergone some major code reorganization (and this has naturally made it difficult to work with external language bindings).
I fixed this issue by remaking samtools with the -fPIC parameter
make clean
make CXXFLAGS=-fPIC CFLAGS=-fPIC CPPFLAGS=-fPIC
then installed using cpan.
cpan[2]> install Bio::DB::Sam
[Solved]
wget http://sourceforge.net/projects/samtools/files/samtools/0.1.18/samtools-0.1.18.tar.bz2
tar xjf samtools-0.1.18.tar.bz2 && cd samtools-0.1.18
make CFLAGS=-fPIC
enter cpan in terminal and enter
install Bio::DB::Sam
Be carefully:
You can not use the following command:
perl -MCPAN -Mlocal::lib -e 'CPAN::install(Bio::DB::Sam)'
You can only use cpan and then use
install Bio::DB::Sam
I followed instructions from README file below of Bio-SamTools-1.43 to edit the Makefile in samtools 0.1.17. Then, to install, I used
perl -MCPAN -e shell
install Bio::DB::Sam
README:
This is a Perl interface to the SAMtools sequence alignment
interface. It ONLY works on versions of Samtools up to 0.1.17. It does
not work on version 1.0 or higher due to major changes in the library
structure.
See http://samtools.sourceforge.net/ for samtools documentation.
ONE-STEP INSTALLATION
In the root directory of this distribution you will find the script
INSTALL.pl. Running this will download the latest versions of this
module and SamTools into a temporary directory, compile them, test and
install. Simply run:
perl INSTALL.pl
MULTI-STEP INSTALLATION
The more traditional install requires you to separately download,
unpack and compile SAMtools 0.1.10 through 0.1.17 in some accessible
directory. Typing "make" in the samtools directory will usually
work. SAMtools versions 0.1.18 and higher do not work with this
library.
Then set the environment variable SAMTOOLS to point to this directory.
You will also need to install Bio::Perl from CPAN.
Now run:
perl Build.PL
./Build
./Build test
(sudo) ./Build install
TROUBLESHOOTING:
If you encounter problems during compiling, you may need to edit
Build.PL so that extra_compiler_flags matches the CFLAGS and DFLAGS
settings in the Samtools Makefile. Here are some common problems:
When building this module, you get an error like the following:
relocation R_X86_64_32 against `a local symbol' can not be used when
making a shared object; recompile with -fPIC
To fix this, edit the Makefile in the Samtools distribution by adding
"-fPIC" to the CFLAGS line. While you're at it, you may also wish to
get rid of a bunch of unused variable warnings that appears under
recent versions of gcc. The modified CFLAGS will look like this
CFLAGS= -g -Wall -Wno-unused -Wno-unused-result -O2 -fPIC #-m64 #-arch ppc
Then do "make clean; make" in the Samtools directory to recompile the
library. After this you should be able to build this module without
errors.
When building this module, you get an error about a missing math
library.
To fix this, follow the recipe in (1) except add -m64 to CFLAGS so it
looks like this:
CFLAGS= -g -Wall -O2 -fPIC #-m64 #-arch ppc
TESTING AND CONTRIBUTING:
You can obtain the most recent development version of this module via
its GitHub site at https://github.com/GMOD/GBrowse-Adaptors. Please
feel free to submit bug reports, patches, etc. via GitHub.
AUTHOR:
Lincoln D. Stein
Copyright (c) 2009-2015 Ontario Institute for Cancer Research
This package and its accompanying libraries are free software; you can
redistribute it and/or modify it under the terms of the Artistic
License 2.0, the Apache 2.0 License, or the GNU General Public License
(version 1 or higher). Refer to LICENSE for the full license text.

How can I tell a CPAN installation of PDL to use my FFTW path?

I need to install the Perl PDL library via CPAN as the non-root user.
CPAN for non-root works thanks to this SO question: How can I use CPAN as a non-root user?
Now, PDL depends on the FFTW library. Evidently, my sysadmin has the 32-bit version installed when I require the 64-bit for this machine.
I base this on the following error message during the CPAN install:
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic FFTW.o -o ../../blib/arch/auto/PDL/FFTW/FFTW.so \
-lm -L/lib -L/usr/lib -L/usr/local/lib -L/usr/local/lib64 -L/lib64 -L/usr/lib64 -ldfftw -ldrfftw \
/usr/bin/ld: skipping incompatible /usr/local/lib/libdfftw.a when searching for -ldfftw
/usr/bin/ld: skipping incompatible /usr/local/lib/libdfftw.a when searching for -ldfftw
/usr/bin/ld: cannot find -ldfftw
Now I have successfully installed fftw in $HOME/lib, indeed libdfftw.a.
The problem is I can't get this gcc compilation instance to use that locally installed copy.
I have tried the following:
Setting LD_LIBRARY_PATH in .bash_profile, and yes, exporting it -- No dice.
Following How can I set library and include paths for Makefile.PL for a single installation?, I set o conf makepl_arg in cpan to: LIBS=-L/homedir/lib INC=-I/homedir/include -- Still no dice
I did the same as step 2 but for o conf mbuild_arg --- Again, no dice.
None of these attempts had any effect on the gcc line above; there were no additional paths specified with -L flags.
What else can I try in cpan to get this compilation command to reference my copy of fftw?
Update 1
I should add that before I make any changes, makepl_arg is:
makepl_arg [INSTALLDIRS=site]
Hence, I am setting makepl_arg to:
makepl_arg [INSTALLDIRS=site LIBS=-L/homedir/lib INC=-I/homedir/include]
I am setting these configurations without doing o conf commit to permit experimentation. Should I be commiting these changes?
Update 2
I see that those -L flags in the above gcc line are coming from the makefile, which itself seems to be made by MakeMaker which I presume is reading the file 'Makefile.PL'
The solution was to examine the .cpan/build/PDL-*/ directory.
In it the INSTALL file indicates that the perldl.conf file can be modified to indicate paths to FFTW libs and FFTW include directories.
The process is as follows and can be done after a failed attempt at installing PDL:
Copy the .cpan/build/PDL-*/perldl.conf file to ~/.perldl.conf - notice the . being added before the filename - PDL will look for this file when installing, even under CPAN
Modify FFTW__LIBS and FFTW_INC in ~/.perldl.conf to point to the appropriate locations.
Attempt install of PDL again with CPAN.
A bit confusing that PDL does not adhere to the makepl_arg cpan configuration.