Error message while compiling a program - c++

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

Related

Windows C++ How to install GLFW library?

I am coding window part of my game. Code gives error. I think the reason of the error is the lack of GLFW library. I am using Notepad++ for editing and MinGW for compiling. How can I install a library to my folder?
Error:
NPP_SAVE: C:\Users\User\Desktop\game\src\main.cpp
CD: C:\Users\User\Desktop\game\src
Current directory: C:\Users\User\Desktop\game\src
g++ "main.cpp" -o main -march=native -O3
Process started (PID=1568) >>>
In file included from main.cpp:4:
Display.h:7:10: fatal error: GLFW/glfw3.h: No such file or directory
#include <GLFW/glfw3.h>
^~~~~~~~~~~~~~
compilation terminated.
<<< Process finished (PID=1568). (Exit code 1)
NPP_RUN: main
; executing: NPP_RUN main
- the specified file was not found
================ READY ================
You don't install a library, you just need to tell the compiler where to find the headers and libraries you require. How you do this depends on your build environment.
If you use only mingw g++ you need the following options:
-I (that's an uppercase i!)(specify path to include files, in your case the path to glfw/include directory)
-L (path to libraries, in your case to the folder that contains glfw3.lib)
-l (that's a lower case L!)(a list of libraries to use, in your case glfw3, without the extension)

How to run a .cpp file with Gecode Framework on Linux?

I use Ubuntu 18.04 and try to compile the example 'money.cpp' file that Gecode brings. I downloaded (gecode-release-5.1.0.tar.gz) and extract it. Then to install Gecode I do the following steps:
(1) ./configure
(2) make
I get satisfactory installation.
Then I try to compile money.cpp, like this:
$g++ money.cpp
and I get the following error:
fatal error: gecode / driver.hh: No such file or directory
  #include
           ^ ~~~~~~~~~~~~~~~~~
I know the problem is that it does not recognize the libraries, but how can I make my .cpp or compile phase recognize them?
regards!
Alberto
You need to call g++ with the -I flag so that g++ knows where to look for the include files:
g++ -I<dir> money.cpp
<dir> is the source code directory for the files (the one with structure as seen on GitHub):
https://github.com/Gecode/gecode
See Compiling with g++:
https://courses.cs.washington.edu/courses/cse373/99au/unix/g++.html

"fatal error: boost/regex.hpp: No such file or directory" when trying to compile C++ program using a makefile

I am trying to compile a piece of open source software called "SPECIES
Identification of Taxonomic Mentions in Text". I am on MacOS.
I downloaded the source code (which can be found here), moved into the directory and used the command make to compile. This is the error returned:
g++ -fpic -pthread -Wall -O3 -o organisms organisms.cxx -lm -lboost_regex
In file included from batch_tagger.h:5:0,
from organisms.cxx:3:
tagger.h:7:27: fatal error: boost/regex.hpp: No such file or directory
compilation terminated.
make: *** [organisms] Error 1
I installed the C++ boost library using brew install boostand tried the above steps again (it did not work).
I tried dropping the boost directory into the directory containing the source code (it did not work).
Any suggestions/help?
You need to tell the compiler where to find boost headers.
You need to use the include path option to specify where the boost headers can be find, use -I/path/to/boost/include.
Then include the file using #include <boost/regex.hpp> from your code.

c++ include directory "file not found"

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

Missing header file

I am new to C++ programming and trying to add a library (Yepp) to my cpp file.
I am trying to compile and it says it cannot find a header file from the external library. The external library, yeppp, has a .so file which I placed in a lib folder in the root directory.
I am building with the following command:
clang++ -O3 test.cpp -o test -L lib/ -lyeppp
Here's the error:
test.cpp:7:10: fatal error: 'yepCore.h' file not found
#include <yepCore.h>
You need to tell the compiler where to find the header file. Use the -I option.