# Open FHE Building Error in Windows 10

**URL:** <https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117>\
**Category:** Library Questions\
**Created:** [September 5, 2022, 2:35pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117 "2022-09-05T14:35:07Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)\
**Post date:** [September 5, 2022, 2:35pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/1 "2022-09-05T14:35:07Z")

</div>

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

```auto
-- 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

```auto
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

```auto
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 🙂

---

<div class="post-metadata">

**Author:** ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)\
**Post date:** [September 5, 2022, 2:49pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/2 "2022-09-05T14:49:33Z")

</div>

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:

```auto
# 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.

---

<div class="post-metadata">

**Author:** ![iquah](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/iquah/32/8_2.png) [@iquah](https://openfhe.discourse.group/u/iquah)\
**Post date:** [September 5, 2022, 3:06pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/3 "2022-09-05T15:06:22Z")

</div>

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)](https://docs.microsoft.com/en-us/windows/wsl/about)? 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.

---

<div class="post-metadata">

**Author:** ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)\
**Post date:** [September 5, 2022, 3:34pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/4 "2022-09-05T15:34:39Z")

</div>

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](https://openfhe-development.readthedocs.io/en/latest/sphinx_rsts/intro/installation/windows.html).

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:

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

Segmentation fault

```

---

<div class="post-metadata">

**Author:** ![iquah](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/iquah/32/8_2.png) [@iquah](https://openfhe.discourse.group/u/iquah)\
**Post date:** [September 6, 2022, 5:49pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/5 "2022-09-06T17:49:15Z")

</div>

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](https://github.com/openfheorg/openfhe-development/issues/176)

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [September 7, 2022, 3:31pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/6 "2022-09-07T15:31:16Z")

</div>

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)

```auto
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile

```

---

<div class="post-metadata">

**Author:** ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)\
**Post date:** [September 9, 2022, 8:42am UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/7 "2022-09-09T08:42:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [September 11, 2022, 3:49pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/8 "2022-09-11T15:49:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [September 12, 2022, 3:04am UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/9 "2022-09-12T03:04:35Z")

</div>

@Pro7ech, both build and segfault bugs have been fixed in the `dev` branch: [GitHub - openfheorg/openfhe-development at dev](https://github.com/openfheorg/openfhe-development/tree/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).

---

<div class="post-metadata">

**Author:** ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)\
**Post date:** [September 12, 2022, 8:53am UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/10 "2022-09-12T08:53:01Z")

</div>

@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`:

```auto
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 :

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

```

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

Then the build failed at this stage:

```auto
[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

```auto
$ git branch
* dev
  main

```

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [September 12, 2022, 12:33pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/11 "2022-09-12T12:33:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)\
**Post date:** [September 12, 2022, 1:03pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/12 "2022-09-12T13:03:15Z")

</div>

@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:

```auto
[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

```

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [September 12, 2022, 1:31pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/14 "2022-09-12T13:31:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dsuponitskiy-duality](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@dsuponitskiy-duality](https://openfhe.discourse.group/u/dsuponitskiy-duality)\
**Post date:** [September 14, 2022, 2:39pm UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/15 "2022-09-14T14:39:14Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Pro7ech](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/pro7ech/32/301_2.png) [@Pro7ech](https://openfhe.discourse.group/u/Pro7ech)\
**Post date:** [September 16, 2022, 8:12am UTC](https://openfhe.discourse.group/t/open-fhe-building-error-in-windows-10/117/16 "2022-09-16T08:12:14Z")

</div>

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