Cannot find definitions of functions from SEAL library

34 views Asked by At

I'm trying to work and configure my project with microsoft seal library using Cmake but I still can't seem to get used to how to link this library and it gives me some errors: Its my CMakeLists:

cmake_minimum_required(VERSION 3.10)
project(FHEProject VERSION 0.1.0 LANGUAGES C CXX)
set(HEADER_FILE_DIR D:/SEAL/native/src)
include_directories(${HEADER_FILE_DIR})

list(APPEND CMAKE_PREFIX_PATH D:/SEAL/build/cmake)

find_package(SEAL 4.1 REQUIRED)

add_executable(${PROJECT_NAME} main.cpp) 

target_link_libraries(${PROJECT_NAME} SEAL::seal)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})

my simple main.cpp:

#include <iostream>
#include<seal/seal.h>
using namespace std;
using namespace seal;
int main(){
    EncryptionParameters parms(scheme_type::bfv);
    for(int i=0;i<10;i++){
        cout<<i<<"\n";
    }
    return 0;
}

its my path: file header seal.h: D:\SEAL\native\src\seal\seal.h file config D:\SEAL\build\cmake\sealconfig.cmake file .lib: "D:\SEAL\build\lib\Debug\seal-4.1.lib

i use option build all project with Cmake tool and get error:

[main] Building folder: pj 
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build d:/pj/build --config Debug --target all -j 10 --
[build] [ 50%] Building CXX object CMakeFiles/FHEProject.dir/main.cpp.obj
[build] [100%] Linking CXX executable FHEProject.exe
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\FHEProject.dir/objects.a(main.cpp.obj):D:/SEAL/native/src/seal/util/globals.h:31:(.text$_ZTWN4seal4util16global_variables15tls_memory_poolE[_ZTWN4seal4util16global_variables15tls_memory_poolE]+0x9): undefined reference to `TLS init function for seal::util::global_variables::tls_memory_pool'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\FHEProject.dir/objects.a(main.cpp.obj): in function `seal::Modulus::Modulus(unsigned long long)':
[build] D:/SEAL/native/src/seal/modulus.h:45:(.text$_ZN4seal7ModulusC1Ey[_ZN4seal7ModulusC1Ey]+0x6a): undefined reference to `seal::Modulus::set_value(unsigned long long)'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\FHEProject.dir/objects.a(main.cpp.obj): in function `seal::EncryptionParameters::EncryptionParameters(seal::scheme_type)':
[build] D:/SEAL/native/src/seal/encryptionparams.h:99:(.text$_ZN4seal20EncryptionParametersC1ENS_11scheme_typeE[_ZN4seal20EncryptionParametersC1ENS_11scheme_typeE]+0xbd): undefined reference to `seal::EncryptionParameters::compute_parms_id()'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\FHEProject.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$.refptr._ZN4seal13parms_id_zeroE[.refptr._ZN4seal13parms_id_zeroE]+0x0): undefined reference to `seal::parms_id_zero'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\FHEProject.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$.refptr.__emutls_v._ZN4seal4util16global_variables15tls_memory_poolE[.refptr.__emutls_v._ZN4seal4util16global_variables15tls_memory_poolE]+0x0): undefined reference to `__emutls_v._ZN4seal4util16global_variables15tls_memory_poolE'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\FHEProject.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$.refptr._ZN4seal4util16global_variables18global_memory_poolE[.refptr._ZN4seal4util16global_variables18global_memory_poolE]+0x0): undefined reference to `seal::util::global_variables::global_memory_pool'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\FHEProject.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$.refptr._ZTVN4seal4util12MemoryPoolMTE[.refptr._ZTVN4seal4util12MemoryPoolMTE]+0x0): undefined reference to `vtable for seal::util::MemoryPoolMT'
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make[2]: *** [CMakeFiles\FHEProject.dir\build.make:100: FHEProject.exe] Error 1
[build] mingw32-make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/FHEProject.dir/all] Error 2
[build] mingw32-make: *** [Makefile:110: all] Error 2
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build d:/pj/build --config Debug --target all -j 10 -- exited with code: 2
[driver] Build completed: 00:00:02.129
[build] Build finished with exit code 2

I can call functions in seal and also include it in main.cpp (it gave me a hint about seal/seal.h) but there seems to be some linker error that I don't not aware of and when When I call the seal functions, it gives me that error

I want it to be able to include the seal library and compile them without errors

0

There are 0 answers