Compiler can't find libxml/parser.h - linux

I am on Debian 8 (Jessie), 64 Bit. I installed libxml2-dev, which now sits in /usr/include/libxml2/libxml.
But when I do (just like libxml docs say)
#include <libxml/parser.h>
I only get when compiling (with gcc)
fatal error: libxml/parser.h: no such file or directory
Notes: On another machine, with an old 64 Bit Suse, where libxml2-dev sits in the exact same path and no other environment vars are set compared to the new Debian, it works perfectly fine. Problem occured while migrating from one to another computer using the exact same makefiles. All other -dev libs that I need just worked (with their documented #include <path>) after the migration (they were all installed with apt-get), only libxml2-dev is not found on compilation.
Do I need to do anything else to make libxml2-dev visible?

if you installed it: sudo apt-get install libxml2-dev libxml2-doc go into /usr/include/libxml2 and copy or move all content from that folder on a level below: cp -R libxml/ ../ After this for me it works.

Try to compile with explicite inclusion where the parser.h file is, i.e. smth like this
g++ -I/usr/include/libxml2/
Following environment variables can also be used for lookup of header files
CPATH
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
Find more information here

I came across this same problem on a Centos system. I resolved it by doing the following:
yum install libxml2-devel
cd /usr/include
ln -s libxml2/libxml .
That was it. No change to environment variables or compiler switches.

You should use pkg-config to pass parameters to compiler. Like this
g++ `pkg-config --cflags libxml-2.0` example.c -o example.o
and to linker:
g++ `pkg-config --libs libxml-2.0` example.o -o example

Related

How to specify the include and lib path of pgm library when making PCA-SIFT code

I am trying to make the PCA-SIFT code (pcasift-0.91nd.tar.gz) in this webpage: http://www.cs.cmu.edu/~yke/pcasift/. After running ./configure which is OK, the make command report that the C compiler can not find header pgm.h:
image.cc:18:22: fatal error: pgm.h: No such file or directory
#include
^ compilation terminated.
There is a webpage in internet which discussed this issue: http://ubuntuforums.org/showthread.php?t=1918422. A solution was stated at the end:
Apparently, the header files are in the directory /usr/include/pgm-5.1
- the preferred way to get this into your include directories when compiling is to use pkgconfig. You will need to add something like
pkg-config --cflags openpgm-5.1 at the end of your compilation
command to get the right headers and add pkg-config --libs
openpgm-5.1 to your linking command.
, but I cannot understand it. Specifically, what does "add pkg-config --cflags openpgm-5.1 at the end of your compilation command" mean? What should I do, to add pkg-config --cflags openpgm-5.1 literally or the results this command returns in terminal? And add to what file? The Makefile is generated by ./configure. Should I add to Makefile or ./configure? I have successfully install libpgm-dev and they are really in /usr/include/pgm-5.1. The command pkg-config --cflags openpgm-5.1 returns -I/usr/include/pgm-5.1 -I/usr/lib/x86_64-linux-gnu/pgm-5.1/include and command pkg-config --libs openpgm-5.1 returns -lpgm -lpthread -lm.
Since that thread was closed, I have to ask here. Hoping someone familiar with Linux compiling process could help me with this issue. Thanks a lot.
I solved the problem myself.
Everything in the ubuntuforums.org webpage mentioned in the original question is wrong; that's why I met with so many problems.
Wrong 1: It's wrong to install libpgm-dev using sudo apt-get install libpgm-dev.
We should download Netpbm, and run the following command after uncompression:
./configure //type none on prompt if you don't have JPEG, TIFF, etc. libraries
make
sudo make package pkgdir=netpbmpkg
sudo ./installnetpbm
sudo rm -f -r /netpbmpkg/
Then Netpbm is installed on Ubuntu.
Wrong 2. The include path returned by pkg-config --cflags is wrong
By default, The include path shold be /usr/local/netpbm/include and the lib path is /usr/local/netpbm/lib.
Wrong 3. The linking option -lpgm returned by pkg-config --libs is wrong
The correct linking option should be -lnetpbm.
Following the right way, I can successfully compile the project in Netbeans (forget about command line make).

Header files are not found by GCC

Working with embedded C-projects. There are libraries, include files and so on - for micro controllers. No need for me to use GCC for a host machine and OS (Linux Mint 64 bit). As a rule...
But now I'm trying to compile mspdebug project from a Github - with a GCC of course. And I get an error at the very begin of make:
mspdebug$ make
cc -DUSE_READLINE -O1 -Wall -Wno-char-subscripts -ggdb -I. -Isimio -Iformats -Itransport -Idrivers -Iutil -Iui -DLIB_DIR=\"/usr/local/lib/\" -o util/btree.o -c util/btree.c
util/btree.c:19:20: fatal error: assert.h: No such file or directory
#include <assert.h>
^
compilation terminated.
I search for the includes in all possible paths (I've got the list of them via gcc -v command) - there are no assert.h file, as well, as stdio.h and so on. Except virtual box directories there is only one place (where GCC does not search includes): /usr/lib/syslinux/com32/include
AFAIK, all standard libs and includes are installed with the GCC. So I try to reinstall GCC (4.8.4) - nothing changes.
What is the normal way to give GCC all standard environment it needs?
Thanks to the right direction set by Sam Varshavchik I found the info in the stackoverflow. So I did the following:
1) installed build-essential:
sudo apt-get install build-essential
2) installed libusb (since my try to build the package revealed the absence of usb.h):
sudo apt-get install libusb-dev
And it is OK! The mspdebug (v.023) is compiled and successfully tested!
So, Linux Mint 17.2 (at least) requires installing some libs to a GCC, the most basic is build-essential.
assert.h is not part of gcc, it's a part of glibc.
Most likely, your Linux distribution puts the system headers into a separate package that you need to install.
Fedora, for examples, puts the header files in the glibc-headers package. However, you can't be using Fedora, because Fedora's gcc package has a dependency on glibc-headers, to make sure that it gets pulled in.
Whatever Linux distribution you're using, you need to research which distribution package will install the system header files you need to build stuff with.

How to add boost library to Code::Blocks in Linux

How to add the boost library to a Code::Blocks project in Linux Ubuntu? For example I want to add regex lib.
I've already installed the boost library with:
sudo apt-get install libboost-all-dev
Full example how to will be most valuable.
Just add -lboost_regex to the link options and you should be fine. Other often used dependencies: -lboost_system -lboost_serialization -lboost_thread -lpthread -lboost_filesystem
Two steps to finish:
Include the header files. If you set everything as default, the headers will be installed at
/usr/include/boost
.
2. Select the links you're going to use during compiling. It's default location is
/usr/lib
ATTENTION:
It seems to me that the
-lboost_system
is always needed. So be careful if you need -lboost_filesystem or some libs else.

manual installation of gcc

i dont have internet connection, so i installed gcc on my linux system manually through its debian package. but i am not able to compile any c code.
here is my sample c code.
#include <stdio.h>
main()
{
printf("Hellp world");
return 0;
}
the error that it shows:
ocpe#blrkec241972d:~$ gcc -o hello hello.c
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function âmainâ:
hello.c:4: warning: incompatible implicit declaration of built-in function âprintfâ
I think i have not installed all the dependencies of compiler. Plz suggest me descriptive way to install it correctly..
Assuming by "installed manually", you mean "using dpkg -i", then you need to also install libc6-dev. I suggest further installing, at very minimum, build-essential and everything it depends on.
Debian actually has a few programs to help with offline package installation. One option is of course to use CD/DVD images. Another is to use something like apt-offline.
On my Debian system, the header files are in another package libc6-dev. You're probably missing that (and some others as well, I would guess).
What about this gcc -Wall hello.c -o hello -I/usr/include/stdio.h?
You can see your include search path by using:
echo | gcc -v -x c -E -
On my Ubuntu Linux machine i can see this output for the previous command:
#include \"...\" search starts here:
/usr/lib/gcc/i686-linux-gnu/4.6.1/include
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed
/usr/include/i386-linux-gnu
/usr/include
EDIT :
Install build-essential
Download from here : http://packages.debian.org/squeeze/i386/build-essential/download (assume you are 32 bits), and install dowloaded package like this:
dpkg -i build-essential.deb

ld cannot find an existing library

I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too.
I am calling the linker with:
g++ -w (..lots of .o files/include directories/etc..) \
-L/usr/lib -lmagic
ld complains:
/usr/bin/ld: cannot find -lmagic
However, libmagic exists:
$ locate libmagic.so
/usr/lib/libmagic.so.1
/usr/lib/libmagic.so.1.0.0
$ ls -all /usr/lib/libmagic.so.1*
lrwxrwxrwx 1 root root 17 2008-12-01 03:52 /usr/lib/libmagic.so.1 -> libmagic.so.1.0.0
-rwxrwxrwx 1 root root 84664 2008-09-09 00:05 /usr/lib/libmagic.so.1.0.0
$ ldd /usr/lib/libmagic.so.1.0.0
linux-gate.so.1 => (0xb7f85000)
libz.so.1 => /usr/lib/libz.so.1 (0xb7f51000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7df6000)
/lib/ld-linux.so.2 (0xb7f86000)
$ sudo ldconfig -v | grep "libmagic"
libmagic.so.1 -> libmagic.so.1.0.0
How do I diagnose this problem further, and what could be wrong? Am I doing something completely stupid?
The problem is the linker is looking for libmagic.so but you only have libmagic.so.1
A quick hack is to symlink libmagic.so.1 to libmagic.so
As just formulated by grepsedawk, the answer lies in the -l option of g++, calling ld. If you look at the man page of this command, you can either do:
g++ -l:libmagic.so.1 [...]
or: g++ -lmagic [...] , if you have a symlink named libmagic.so in your libs path
It is Debian convention to separate shared libraries into their runtime components (libmagic1: /usr/lib/libmagic.so.1 → libmagic.so.1.0.0) and their development components (libmagic-dev: /usr/lib/libmagic.so → …).
Because the library's soname is libmagic.so.1, that's the string that gets embedded into the executable so that's the file that is loaded when the executable is run.
However, because the library is specified as -lmagic to the linker, it looks for libmagic.so, which is why it is needed for development.
See Diego E. Pettenò: Linkers and names for details on how this all works on Linux.
In short, you should apt-get install libmagic-dev. This will not only give you libmagic.so but also other files necessary for compiling like /usr/include/magic.h.
In Ubuntu, you can install libtool which resolves the libraries automatically.
$ sudo apt-get install libtool
This resolved a problem with ltdl for me, which had been installed as libltdl.so.7 and wasn't found as simply -lltdl in the make.
As mentioned above the linker is looking for libmagic.so, but you only have libmagic.so.1.
To solve this problem just perform an update cache.
ldconfig -v
To verify you can run:
$ ldconfig -p | grep libmagic
Unless I'm badly mistaken libmagic or -lmagic is not the same library as ImageMagick. You state that you want ImageMagick.
ImageMagick comes with a utility to supply all appropriate options to the compiler.
Ex:
g++ program.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs` -o "prog"
Installing libgl1-mesa-dev from the Ubuntu repo resolved this problem for me.
I tried all solutions mentioned above but none of them solved my issue but finally I solved it with the following command.
sudo apt-get install libgmp3-dev
This will do the magic.
Another way to solve this problem is to install the -devel package.
If the compiler is looking for libabc.so while you have libabc.so.1, you need to install the -devel package like libabc-devel as libabc.so.1 is a runtime lib but libabc.so is a development lib.

Resources