Failed to build my own "boolean.cpp"

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.

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. :slightly_smiling_face:

my_example
----boolean
--------build
--------CMakeLists.txt
--------myboolean.cpp
--------PreLoad.cmake

  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?

  1. GitHub - shiuannnnn/my_example
    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.)

Noted. I’ve marked the issue as solved