Open FHE Building Error in Windows 10

Hi there,

I’m new to C++, so I blindly followed the installation guidelines for Windows 10.

Up to calling cmake .. everything went smoothly (although a few tests failed, such as

-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile

but it doesn’t end with an error.)

However, while building the library, the compiler is throwing a lot of warnings, such as

C:/msys64/home/Zybeline/openfhe-development/src/core/include/math/distributiongenerator.h: In static member function 'static lbcrypto::PRNG& lbcrypto::PseudoRandomNumberGenerator::GetPRNG()':
C:/msys64/home/Zybeline/openfhe-development/src/core/include/math/distributiongenerator.h:132:26: warning: pointer 'mem' used after 'void free(void*)' [-Wuse-after-free]
  132 |                 uint32_t counter = reinterpret_cast<long long>(mem);  // NOLINT
      |                          ^~~~~~~
C:/msys64/home/Zybeline/openfhe-development/src/core/include/math/distributiongenerator.h:131:21: note: call to 'void free(void*)' here
  131 |                 free(mem);
      |   

By default, any warning is interpreted as an error, and the build fails. So I disabled that option, and the build went up to 73% where it threw an actual error and failed

C:/msys64/home/Zybeline/openfhe-development/src/binfhe/unittest/UnitTestFunc.cpp: In member function 'virtual void UnitTestFHEWGINX_EvalArbFunc_Test::TestBody()':
C:/msys64/home/Zybeline/openfhe-development/src/binfhe/unittest/UnitTestFunc.cpp:69:19: error: 'uint' was not declared in this scope; did you mean 'usint'?
   69 |         EXPECT_EQ(uint(fp(i, p).ConvertToInt()), result) << failed;
      |                   ^~~~

Any clue why this is happening and how to fix it?

Edit: I tried from a clean install on two separate computers, both running Windows 10, and I get in the same trouble.

Thanks :slight_smile:

1 Like

I would like to add that building the examples works fine, as long as the flag to interpret warning as error is disabled.

However, when trying to run any example, the following error is thrown:

# bin/examples/pke/simple-integers
C:/msys64/home/Zybeline/openfhe-development/build/bin/examples/pke/simple-integers.exe: error while loading shared libraries: libOPENFHEpke.dll: cannot open shared object file: No such file or directory

The file libOPENFHEpke.dll is present in the folder build/lib

Edit: I tried to add the path to the environment variables, but it didn’t solve it. What solved it was copy-pasting the missing file in the example folder.

So, this doesn’t answer your question, but is there a specific reason you’re doing this in traditional windows, as opposed to using Windows Subsystem for Linux (WSL)? I think all of us on the dev team use WSL or some flavor of Linux to do our development so that has better support.

Having said that, I’ll definitely reach out to the other devs, and hopefully we can get your windows build issue resolved.

I agree that if I was running it on Linux, I would, as usual, most likely not have all these errors. However, the documentation states that MinGW (64-bit) on Windows 10 is supported and continually tested, and I followed the instructions provided here.

I managed to build the examples (by intentionally omitting the problematic files and changing the error flag), and run most of them without trouble (once I fixed the path of the .dll file).

Still, I get the following error for the ones involving the CKKS bootstrapping:

# bin/examples/pke/simple-ckks-bootstrapping
CKKS scheme is using ring dimension 4096

Segmentation fault

Gotcha! Thanks for the patience. We’ve assigned it to someone and you can view the issue tracker here: github openfhe - Build error on MinGW (64-bit) on Windows

Yes, we do support MinGW. I just tried compiling OpenFHE from the main branch and got the same compilation error as @Pro7ech So it is a bug that can be easily recreated.

Note that the first CMake warning can be ignored (no issue here)

-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
1 Like

Any idea why I get a Segmentation fault when trying to run the CKKS bootstrapping example? Would it be worth opening a new issue? It might or might not be related to this issue, it is hard to tell since the error message doesn’t say a lot and the examples are part of the files that compiled without issue.

Hi @Pro7ech,

@dsuponitskiy-duality should fix the MinGW compilation bug tomorrow (in the dev branch). After that I want to try the bootstrapping example in MinGW. We don’t have any problem running bootstrapping examples in regular Linux environments. So this segfault issue appears to be MinGW-specific. I want to confirm first.

@Pro7ech, both build and segfault bugs have been fixed in the dev branch: GitHub - openfheorg/openfhe-development at dev Please give it a try in you MinGW environment. If all looks good, we will push this to the main branch (release a new version: 0.9.3).

@ypolyakov , thank you for being so quick. I updated the MinGW environement, cloned dev and tried to build. I still had to delete -Werror from two following lines out of the CMakelist.txt:

set(C_COMPILE_FLAGS "-Wall -Werror -O3 ${NATIVE_OPT} -DOPENFHE_VERSION=${OPENFHE_VERSION}")
set(CXX_COMPILE_FLAGS "-Wall -Werror -O3 ${NATIVE_OPT} -DOPENFHE_VERSION=${OPENFHE_VERSION} ${IGNORE_WARNINGS}")

else it would fail on the first warning (the same as the original post).

The warnings tags are :

-Werror=use-after-free
-Wdeprecated-declarations

The vast majority of the warnings originate from third-party/cereal.

Then the build failed at this stage:

[ 73%] Building CXX object src/binfhe/CMakeFiles/binfhe_tests.dir/unittest/UnitTestFunc.cpp.obj
make[2]: *** [src/binfhe/CMakeFiles/binfhe_tests.dir/build.make:122: src/binfhe/CMakeFiles/binfhe_tests.dir/unittest/UnitTestFunc.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1561: src/binfhe/CMakeFiles/binfhe_tests.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I made sure I’m in the correct branch

$ git branch
* dev
  main

@Pro7ech , could you delete the current directory and build (and even) clone from scratch. Just want to confirm there is nothing left from the previous build.

I built in MinGW yesterday and everything worked without any problems. If you still have the issue after a clean buld, could you post here the versions of cmake and make? Thanks.

@ypolyakov

I’m using cmake-3.23.2-1-x86_64 and make-4.3-3.

So, I deleted the repo, recloned everything, checked out to dev, mdkir build, cd build, cmake .. and make, it ended up with the following error:

[ 25%] Building CXX object src/core/CMakeFiles/core_tests.dir/unittest/UnitTestSerialize.cpp.obj
In file included from C:/msys64/home/Zybeline/openfhe-development/third-party/cereal/include/cereal/archives/json.hpp:62,
                 from C:/msys64/home/Zybeline/openfhe-development/src/core/include/utils/serial.h:65,
                 from C:/msys64/home/Zybeline/openfhe-development/src/core/unittest/UnitTestSerialize.cpp:49:
C:/msys64/home/Zybeline/openfhe-development/third-party/cereal/include/cereal/external/rapidjson/document.h:102:19: error: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Werror=deprecated-declarations]
  102 |     : public std::iterator<std::random_access_iterator_tag
      |                   ^~~~~~~~
In file included from C:/msys64/mingw64/include/c++/12.2.0/string:45,
                 from C:/msys64/mingw64/include/c++/12.2.0/bits/locale_classes.h:40,
                 from C:/msys64/mingw64/include/c++/12.2.0/bits/ios_base.h:41,
                 from C:/msys64/mingw64/include/c++/12.2.0/ios:42,
                 from C:/msys64/mingw64/include/c++/12.2.0/ostream:38,
                 from C:/msys64/mingw64/include/c++/12.2.0/iostream:39,
                 from C:/msys64/home/Zybeline/openfhe-development/src/core/unittest/UnitTestSerialize.cpp:36:
C:/msys64/mingw64/include/c++/12.2.0/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
C:/msys64/home/Zybeline/openfhe-development/third-party/cereal/include/cereal/external/rapidjson/document.h:110:18: error: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Werror=deprecated-declarations]
  110 |     typedef std::iterator<std::random_access_iterator_tag,ValueType> BaseType;
      |                  ^~~~~~~~
C:/msys64/mingw64/include/c++/12.2.0/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
cc1plus.exe: all warnings being treated as errors
make[2]: *** [src/core/CMakeFiles/core_tests.dir/build.make:317: src/core/CMakeFiles/core_tests.dir/unittest/UnitTestSerialize.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:633: src/core/CMakeFiles/core_tests.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

@Pro7ech I was able to recreate the issue by running pacman -Syu (basically it updated gcc from 11 to 12.2). We are going to look into it.

1 Like

@Pro7ech All fixes to the issues mentioned above have been merged in to the dev branch. Please confirm that you don’t see any failures using the dev branch. Thank you

@dsuponitskiy-duality Everything compiled fine and the ckks bootstrapping example ran fine too. Thank you very much :slight_smile: