Static library seems not properly generated

I tried to get static library by using following CMake options;

    cmake -S .\
          -DCMAKE_BUILD_TYPE=Release\
          -DCMAKE_INSTALL_PREFIX=${DIR_PREFIX}\
          -DMATHBACKEND=2\
          -DWITH_OPENMP="OFF"\
          -DBUILD_DYNAMIC=OFF\
          -DBUILD_STATIC=ON\
          -DCMAKE_CXX_FLAGS="-g "\
          ..

It generates following static libraries along with dynamic libraries.
libOPENFHEbinfhe.so
libOPENFHEbinfhe.so.1
libOPENFHEbinfhe.so.1.0.2
libOPENFHEbinfhe_static.a
libOPENFHEcore.so
libOPENFHEcore.so.1
libOPENFHEcore.so.1.0.2
libOPENFHEcore_static.a
libOPENFHEpke.so
libOPENFHEpke.so.1
libOPENFHEpke.so.1.0.2
libOPENFHEpke_static.a

However "undefined reference " errors occur while liking stage as followings.
g++ -c -g -O0 -Werror -std=c++11 -I/include -Iopenfhe/include/openfhe -Iopenfhe/include/openfhe/core -Iopenfhe/include/openfhe/pke src/main.cpp -o obj/main.o
g++ -o test -O0
obj/main.o
-Wl,-Bstatic -Lopenfhe/lib -lOPENFHEbinfhe_static -lOPENFHEcore_static -lOPENFHEpke_static -Wl,-Bdynamic -lntl
/usr/bin/ld: openfhe/lib/libOPENFHEpke_static.a(bfvrns-parametergeneration.cpp.o): in function lbcrypto::StdLatticeParm::FindRingDim(lbcrypto::DistributionType, lbcrypto::SecurityLevel, unsigned int)': openfhe/openfhe-development/src/core/include/lattice/stdlatticeparms.h:139: undefined reference to lbcrypto::StdLatticeParm::initialized’
/usr/bin/ld: openfhe/openfhe-development/src/core/include/lattice/stdlatticeparms.h:139: undefined reference to lbcrypto::StdLatticeParm::byLogQ' /usr/bin/ld: openfhe/lib/libOPENFHEpke_static.a(bfvrns-parametergeneration.cpp.o): in function lbcrypto::StdLatticeParm::initializeLookups()‘:
openfhe/openfhe-development/src/core/include/lattice/stdlatticeparms.h:119: undefined reference to lbcrypto::StdLatticeParm::StandardLatticeParmSets' /usr/bin/ld: openfhe/openfhe-development/src/core/include/lattice/stdlatticeparms.h:119: undefined reference to lbcrypto::StdLatticeParm::StandardLatticeParmSets’

~

it may be that you are linking libraries out of order. try linking core first then pke then binfhe
note you do not need binfhe if you are not using the binfhe schemes.

It has been solved and it was linking order problem.

Use following order;
-L$(DIR_OPENFHE_LIB)
-lOPENFHEpke_static
-lOPENFHEcore_static

or use linking group option as follows.
-Wl,–start-group -L$(DIR_OPENFHE_LIB) -lOPENFHEpke_static -lOPENFHEcore_static -Wl,–end-group