Compilation failed

Hi,

I’m a beginner in C++, so my doubt may seem basic, but I’m struggling to solve this problem.

I’m trying to compile the example simple-real-number.cpp by myself using g++ simple-real-number.cpp command, but I get the following error:

src/pke/examples/simple-real-numbers.cpp:38:10: fatal error: openfhe.h: No such file or directory
 #include "openfhe.h"
          ^~~~~~~~~~~
compilation terminated.

Why the compilation is not finding the header file? Is this an installation problem, or something else? Can someone help me?

Hello:

Please read the CMake build instructions located here:

https://openfhe-development.readthedocs.io/en/latest/sphinx_rsts/intro/installation/cmake_in_openfhe.html

To be more concise, there is no need to invoke g++ directly. Here are the steps that you might use in a terminal under Linux to build the library, and the example you are interested in:

clone the openfhe repository
cd into the repository’s local copy directory
mkdir build
cd build
cmake [any cmake options you want] ..
make -j

Without any cmake options, the example you are interested in is built by default. The binary can be found in:

[repo local copy]/build/bin/examples/simple-real-numbers

You can modify the code in-tree, and re-run make -j in the build directory if you make changes.

I hope this gets you past your issue. If not, please feel free to continue this thread with any questions.

Jack Bates
Duality

2 Likes

Thanks a lot!

I could modify the file and re-run make-j to recompile the example!

Glad to hear it!

Let us know if you have any other issues.

Jack Bates
Duality

Hi,

Same here, I’m a beginner in C++. I’m on Windows 10, and followed the installation guide. Everything went smoothly, until the make command, where I get the following error:

# make
[  0%] Built target third-party
Consolidate compiler generated dependencies of target coreobj
[  1%] Building CXX object src/core/CMakeFiles/coreobj.dir/lib/lattice/hal/default/dcrtpoly-impl.cpp.obj
In file included from C:/msys64/home/Pro7ech/openfhe-development/src/core/include/math/discretegaussiangenerator.h:77,
                 from C:/msys64/home/Pro7ech/openfhe-development/src/core/include/lattice/ilelement.h:42,
                 from C:/msys64/home/Pro7ech/openfhe-development/src/core/include/lattice/hal/dcrtpoly-interface.h:52,
                 from C:/msys64/home/Pro7ech/openfhe-development/src/core/include/lattice/hal/default/dcrtpoly.h:51,
                 from C:/msys64/home/Pro7ech/openfhe-development/src/core/include/lattice/hal/default/lat-backend-default.h:39,
                 from C:/msys64/home/Pro7ech/openfhe-development/src/core/include/lattice/lat-hal.h:42,
                 from C:/msys64/home/Pro7ech/openfhe-development/src/core/lib/lattice/hal/default/dcrtpoly.cpp:39,
                 from C:/msys64/home/Pro7ech/openfhe-development/src/core/lib/lattice/hal/default/dcrtpoly-impl.cpp:36:
C:/msys64/home/Pro7ech/openfhe-development/src/core/include/math/distributiongenerator.h: In static member function 'static lbcrypto::PRNG& lbcrypto::PseudoRandomNumberGenerator::GetPRNG()':
C:/msys64/home/Pro7ech/openfhe-development/src/core/include/math/distributiongenerator.h:132:26: error: pointer 'mem' used after 'void free(void*)' [-Werror=use-after-free]
  132 |                 uint32_t counter = reinterpret_cast<long long>(mem);  // NOLINT
      |                          ^~~~~~~
C:/msys64/home/Pro7ech/openfhe-development/src/core/include/math/distributiongenerator.h:131:21: note: call to 'void free(void*)' here
  131 |                 free(mem);
      |                 ~~~~^~~~~
cc1plus.exe: all warnings being treated as errors
make[2]: *** [src/core/CMakeFiles/coreobj.dir/build.make:197: src/core/CMakeFiles/coreobj.dir/lib/lattice/hal/default/dcrtpoly-impl.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:551: src/core/CMakeFiles/coreobj.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Any help would be appreciated :slight_smile:

Hey there, @Pro7ech !

Would you mind opening up a new thread? Mostly because your error seems to be different from what this user was running into

1 Like