How to link OpenFHE libraries in Windows

Hi,
I installed the OpenFHE using MSYS2 MINGW 64-bit shell in my Windows OS. I followed the instructions on this page

I was able to run the simple-integers executable in

cd \~/openfhe-development/build/bin/examples/pke ./simple-integers

However, I wanted to create my own simple OpenFHE C++ program. So, in the same mingw64 shell, I created a directory
~/simple_openfhe

and inside it, a simple OpenFHE C++ program named main.cpp. However, I am having a hard time compiling and building the program because it doesn’t recognize the (#include “openfhe.h” ). After navigating around, I found that in my (C:/Program Files (x86)/OpenFHE/), I have three directories “CMake” and “include” and “lib”. So, I created the following CMakeLists.txt file in my ~/simple_openfhe file to link the libraries.

#Begining of my CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(simple_openfhe)

#Include headers
include_directories(“C:/Program Files (x86)/OpenFHE/include”)

#Link libraries manually
link_directories(“C:/Program Files (x86)/OpenFHE/lib”)

add_executable(simple_openfhe main.cpp)

target_link_libraries(simple_openfhe
OPENFHEcore
OPENFHEpke
OPENFHEbinfhe
)

Then, I created a build directory
mkdir \~/simple_openfhe/build cd build

Then I did a
$ cmake ..

I did not get an error, but it didn’t create a “Makefile” so when I did

$make
It says make: *** No targets specified and no makefile found. Stop.

I am not sure if I doing the right thing, but my aim is to compile, build, and run my simple OpenFHE C++ program main.cpp. I tried with Visual Studio Code, but I got the same error of not recognizing the #include “openfhe.h”. So, I went to the mingw64 shell. Can someone please help me with either one.

Thank you

The recommended way: to create a user application, follow the guidelines here.

The not recommended way: a quick but less clean way to solve your problem is to create your application inside the examples folder, where you could run the example simple-integers.

1 Like

Thank you very much! I did it the recommeded way in which I followed the guidlines and it worked.