# Failed to build my own "boolean.cpp"

**URL:** <https://openfhe.discourse.group/t/failed-to-build-my-own-boolean-cpp/304>\
**Category:** Library Questions\
**Tags:** questions\
**Created:** [January 16, 2023, 2:45pm UTC](https://openfhe.discourse.group/t/failed-to-build-my-own-boolean-cpp/304 "2023-01-16T14:45:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shiuan](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Shiuan](https://openfhe.discourse.group/u/Shiuan)\
**Post date:** [January 16, 2023, 2:45pm UTC](https://openfhe.discourse.group/t/failed-to-build-my-own-boolean-cpp/304/1 "2023-01-16T14:45:34Z")

</div>

Hello everyone,  
In order to learn how to build my own project, I am trying to build “boolean.cpp” as my “demo-simple-example.cpp” first, however it came out with some error.

```auto
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text+0xae5): undefined reference to `intnat::NativeVectorT<intnat::NativeIntegerT<unsigned long long> >::~NativeVectorT()'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text+0xb01): undefined reference to `intnat::NativeVectorT<intnat::NativeIntegerT<unsigned long long> >::~NativeVectorT()'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text+0xb20): undefined reference to `intnat::NativeVectorT<intnat::NativeIntegerT<unsigned long long> >::~NativeVectorT()'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text+0xb49): undefined reference to `intnat::NativeVectorT<intnat::NativeIntegerT<unsigned long long> >::~NativeVectorT()'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text+0xb6b): undefined reference to `intnat::NativeVectorT<intnat::NativeIntegerT<unsigned long long> >::~NativeVectorT()'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text+0xb91): more undefined references to `intnat::NativeVectorT<intnat::NativeIntegerT<unsigned long long> >::~NativeVectorT()' follow
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0xaa): undefined reference to `lbcrypto::BinFHEContext::GenerateBinFHEContext(lbcrypto::BINFHE_PARAMSET, lbcrypto::BINFHE_METHOD)'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0xb7): undefined reference to `lbcrypto::BinFHEContext::KeyGen() const'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0x10b): undefined reference to `lbcrypto::BinFHEContext::BTKeyGen(std::shared_ptr<lbcrypto::LWEPrivateKeyImpl const>)'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0x1a8): undefined reference to `lbcrypto::BinFHEContext::Encrypt(std::shared_ptr<lbcrypto::LWEPrivateKeyImpl const>, long long const&, lbcrypto::BINFH
E_OUTPUT, unsigned long long, intnat::NativeIntegerT<unsigned long long>) const'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0x218): undefined reference to `lbcrypto::BinFHEContext::Encrypt(std::shared_ptr<lbcrypto::LWEPrivateKeyImpl const>, long long const&, lbcrypto::BINFH
E_OUTPUT, unsigned long long, intnat::NativeIntegerT<unsigned long long>) const'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0x282): undefined reference to `lbcrypto::BinFHEContext::EvalBinGate(lbcrypto::BINGATE, std::shared_ptr<lbcrypto::LWECiphertextImpl const>, std::share
d_ptr<lbcrypto::LWECiphertextImpl const>) const'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0x2d6): undefined reference to `lbcrypto::BinFHEContext::EvalNOT(std::shared_ptr<lbcrypto::LWECiphertextImpl const>) const'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0x346): undefined reference to `lbcrypto::BinFHEContext::EvalBinGate(lbcrypto::BINGATE, std::shared_ptr<lbcrypto::LWECiphertextImpl const>, std::share
d_ptr<lbcrypto::LWECiphertextImpl const>) const'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0x3c6): undefined reference to `lbcrypto::BinFHEContext::EvalBinGate(lbcrypto::BINGATE, std::shared_ptr<lbcrypto::LWECiphertextImpl const>, std::share
d_ptr<lbcrypto::LWECiphertextImpl const>) const'
D:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/myboolean.dir/objects.a(myboolean.cpp.obj):myboolean.cp
p:(.text.startup+0x446): undefined reference to `lbcrypto::BinFHEContext::Decrypt(std::shared_ptr<lbcrypto::LWEPrivateKeyImpl const>, std::shared_ptr<lbcrypto::LWECiph
ertextImpl const>, long long*, unsigned long long) const'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/myboolean.dir/build.make:101: myboolean.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/myboolean.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

```

The error seems like it doesn’t know the function defined in namespace lbcrypto, so I am wondering if it cannot find the “binfhecontext.cpp” or did I miss something?

(I had completed “make install” and copied the CMakeLists.User.txt (modified) and PreLoad.cmake into my boolean folder.)

Here are the hierarchy of my folder and thanks for the reading. 🙂

> my\_example  
> ----boolean  
> --------build  
> --------CMakeLists.txt  
> --------myboolean.cpp  
> --------PreLoad.cmake

---

<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:** [January 16, 2023, 6:31pm UTC](https://openfhe.discourse.group/t/failed-to-build-my-own-boolean-cpp/304/2 "2023-01-16T18:31:40Z")

</div>

1. Can you share a URL to your repo? I’d like to see the contents. It’s a bit hard to debug without having access to the code.

2. Are you able to run the examples within OpenFHE?

---

<div class="post-metadata">

**Author:** ![Shiuan](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Shiuan](https://openfhe.discourse.group/u/Shiuan)\
**Post date:** [January 17, 2023, 12:40am UTC](https://openfhe.discourse.group/t/failed-to-build-my-own-boolean-cpp/304/3 "2023-01-17T00:40:04Z")

</div>

1. [GitHub - shiuannnnn/my\_example](https://github.com/shiuannnnn/my_example.git)  
Here are the contents, and “myboolean.cpp” just same as your example.

2. Yes, I have almost test all the examples in binfhe without any error.

Edit: After using the shared library instead of static library (BUILD\_STATIC=OFF), the error fixed and now I can see the execution file. But it occurred another problem that the execution file cannot be executed.

Edit2: The problem solved when I put the execution file into the folder where I build examples within OpenFHE. (Seems weird but my problem is temporary solved, I think I need to be familiar with some environment settings.)

---

<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:** [January 18, 2023, 4:01pm UTC](https://openfhe.discourse.group/t/failed-to-build-my-own-boolean-cpp/304/4 "2023-01-18T16:01:48Z")

</div>

Noted. I’ve marked the issue as solved
