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
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’m a newbie to C++ and Linux. There is this code I’m playing with that requires me to install the HElib (Homomorphic encryption library and other libraries - GMP, NTL) which I did. I want to compile the code (main.cpp) that has a header file (FHE.h) in HElib. My problem is how can I link FHE.h (in HElib folder) and main.cpp (in another folder) together so that I can compile them. I have tried some commands
g++ -I/Home/HElib/src/FHE.h main.cpp -o main
Error message
main.cpp:1:17: fatal error: FHE.h: No such file or directory
compilation terminated.
Another command line
g++ -I/Home/HElib/Src/FHE.h -I/Home/SimpleFHESum-master/SimpleFHESum-master/main.cpp -o main]
Error Message
g++: fatal error: no input files
compilation terminated.
What's wrong and how can I fix this?
The -I flag adds the following directory to the include path of the compiler. This enables you to write e.g. #include "FHE.h" even though that file is not located in the same folder as the source file you're trying to compile.
Have you tried just removing the 'FHE.h' part from your -I directive?
g++ -I/Home/HElib/src ...
I am trying to execute a cpp file named "palindrome.cpp" using terminal on my Macbook. This cpp file uses an external library named "libStanfordCPPLib.a" which lies under "DIRECTORY TO CPP FILE/StanfordCPPLib", also the corresponding header files of this library are in this "StanfordCPPLib" folder.
You can see the folder structure by this screenshot:
My code for compiling this source code is :
g++-4.8 -Wall -I/Users/myName/Downloads/CS106B/palindrome/StanfordCPPLib -L/Users/myName/Downloads/CS106B/palindrome/StanfordCPPLib palindrome.cpp libStanfordCPPLib.a
As I understand, -I stands for the directory path where header files exist, and -L stands for the directory path where library (.a file) exists. That's why both -I and -L are the same directory path "/Users/myName/Downloads/CS106B/palindrome/StanfordCPPLib".
However, executing this command returns an error saying :"libStanfordCPPLib.a: No such file or directory". As is shown in the screenshot:
Can anyone see why this happens? Thanks.
Try this, using -lStanfordCPPLib:
g++-4.8 -Wall -I/Users/myName/Downloads/CS106B/palindrome/StanfordCPPLib -L/Users/myName/Downloads/CS106B/palindrome/StanfordCPPLib palindrome.cpp -lStanfordCPPLib
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.
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.