HI,
I have the following: #include <libxml++/libxml++.h> and when i compile it says fatal error: libxml++/libxml++.h.No such file or directory. I've checked in the directory: /usr/include/libxml++-2.6/libxml++ and there it is the libxml++.h. Where am I wrong? why do i receive this error? thx
EDIT:
I did include g++ prg.cpp -o prg -I/usr/include/libxml++-2.6/ and now i have the
error:fatal error: glibmm/ustring.h: No such file or directory
You should use pkg-config to get the correct compiler options. See, for instance:
http://developer.gnome.org/libxml++/stable/
Add the following option in the makefile:
g++ <some options> -I/usr/include/libxml++-2.6 <some other options>
The -I flag in g++ adds the directory appearing after it to the include path. If you do not want to use that option, you need to replace the #include<libxml++-2.6/libxml++.h> with #include "absolute path to above header file". Note that using the -I flag also allows you to replace " " after the #include with < > tags.
add -I/usr/include/libxml++-2.6/libxml++ when compiling.
Related
I have never used a package manager for C++ packages until today. I finally got one to semi work, called cget. I'm trying to use a package called nlohmann/json and from their documentation I just need to run cget install nlohmann/json. The issue is that this puts the include header files in the directory /cget/include/nlohmann which (I assume) the g++ compiler doesn't look in for headers. So I manually moved the nlohmann directory into the /usr/include directory. When I compile with g++ test.cpp -o test it fails with the error "No such file of directory". I clearly see the file in the include path, so what am I missing?
// test.cpp
#include <nlohmann/json.hpp>
I've tried using the Include flag g++ -I /usr/include test.cpp -o test and it still fails.
The path to the json.hpp file is /usr/include/nlohmann/json.hpp
When I run `g++ -print-prog-name=cc1plus` -v it gives:
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/9
/usr/include/x86_64-linux-gnu/c++/9
/usr/include/c++/9/backward
/usr/lib/gcc/x86_64-linux-gnu/9/include
/usr/local/include
/usr/include
End of search list.
What is causing this error to persist?
I am trying to compile a cpp using with the following command:
g++ -IC:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\include\curl -LC:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\lib program.cpp
this program has a header file which uses libcurl. the curl library is at -
C:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\include\curl\curl.h
gcc gives the following error even though curl.h is in the path -I
mylibrary.h:26:10: fatal error: curl/curl.h: No such file or directory
#include <curl/curl.h>
what am I doing wrong?
The error message means the file curl/curl.h could not be found in the search path specified by -I. You updated the question with the path to the file so the command should be:
g++ -IC:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\include -LC:\Users\XXX\libcurl-7.56.0\libcurl-7.56.0\lib program.cpp
Also, can you please try using \ instead of / as path separator in your mylibrary.h file:
#include <curl\curl.h>
I'm working on getting an example run for the audioCaffe framework http://multimedia-commons.s3-website-us-west-2.amazonaws.com/?prefix=tools/audioCaffe/
The root directory of this project contains an include directory.
Except, when I navigate to tools and compile g++ caffe.cpp it throws an error:
caffe.cpp:8:10: fatal error: 'caffe/caffe.hpp' file not found
note that include/caffe/caffe.hpp exists
Since you mentioned using g++ caffe.cpp I assume you execute this command form where caffe.cpp file is, which is:
audioCaffe/tools/caffe.cpp
The caffe.cpp file uses #include "caffe/caffe.hpp" which is in the include directory:
audioCaffe/include/caffe/caffe.hpp
So you will need to tell the compiler where to find the headers, you do this with the -I option. Compile it with the command:
g++ -I ../include caffe.cpp
I am trying to compile a source file driver.cxx and among its include files is a library called
The path to this file is /home/terry/Downloads/libodb-2-4-0/odb/sqlite/database.hxx
to compile it I enter the following:
g++ -c driver.cxx -I/home/terry/Downloads/libodb-2.4.0/odb
And get the message
driver.cxx:10:35: fatal error: odb/sqlite/database.hxx: No such file
or directory #include
^ compilation terminated.
How do I mention the path when using the -I flag for g++?
According to the error you pasted it looks like your include command is:
#include "odb/sqlite/database.hxx"
If so, your -I option should be without odb dir (since it's already mentioned in the include):
-I/home/terry/Downloads/libodb-2.4.0/
All in all the -I concatenated with the include should be the exact path.
Meaning if you decide to include with:
#include "database.hxx"
Your -I option should be:
-I/home/terry/Downloads/libodb-2.4.0/odb/sqlite
Again, -I + include = exact path.
Since the error message mentions 'odb' part of the path I would remove it from -I flag
Let's say you want to use database.hxx in your .cpp file. Then in your .cpp file you should write:
#include "database.hxx"
and for compiling you should mention the path where the .h is present. So in your case it would be.
-I /home/terry/Downloads/libodb-2-4-0/odb/sqlite/
I can see that your error mentions you use #include <odb/sqlite/database.hxx>. Try to change it to #include <database.hxx>.
I tried to apply preprocessor to a C++ header file with Macros using the below command.
$ g++ -E heap.h
And I wasn't able to get the preprocessed header file, because preprocessing was finished with the below error.
...
...
# 9 "heap.h" 2
heap.h:10:28: fatal error: src/allocation.h: No such file or directory
To tell g++ about the directories that includes header file included in heap.h, I typed the below command, but it showed the same error.
$ g++ -E heap.h -I .
...
...
heap.h:10:28: fatal error: src/allocation.h: No such file or directory
Can you leave the solution of this problem if you have an experience that you solve this problem?
The steps:
You may need to change to the directory from where your build system invokes the command if the command does not use absolute paths.
Copy the compiler command line from your make/cmake/etc. output.
Add -E switch.
Add/change -o parameter to <source>.i.