Cannot link to Crypto++ on Debian due to undefined references - c++

I have a project that depends on Crypto++ on Debian 8.10. The project has a library (called common that uses Crypto++ ) and the executable (hwinfo). I'm using Cmake for building purposes.
Here is my library build Cmake:
cmake_minimum_required(VERSION 3.2.2)
set (CMAKE_CXX_STANDARD 11)
include_directories()
file(GLOB SOURCES "*.cpp")
project(common)
add_library(common ${SOURCES})
find_library(LIBCRYPTOPP cryptopp)
target_link_libraries(common ${LIBCRYPTOPP})
install(TARGETS common
ARCHIVE DESTINATION ${PROJECT_SOURCE_DIR}/../../lib
LIBRARY DESTINATION ${PROJECT_SOURCE_DIR}/../../lib)
And my executable Cmake file:
cmake_minimum_required(VERSION 3.2.2)
set (CMAKE_CXX_STANDARD 11)
include_directories(../common)
file(GLOB SOURCES "*.cpp")
project(hwinfo)
add_executable(hwinfo ${SOURCES})
find_library(LIBCOMMON common PATHS ${PROJECT_SOURCE_DIR}/../../lib)
find_library(LIBCRYPTOPP cryptopp)
message(STATUS "CRYPTO LIBRARY ===>" ${LIBCRYPTOPP})
message(STATUS "MY COMMON LIBRARY ===>" ${LIBCOMMON})
target_link_libraries(hwinfo ${LIBCRYPTOPP} ${LIBCOMMON})
install(TARGETS hwinfo
RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/../../bin)
From the diagnostic messages in the executable Cmake (message (STATUS...)):
-- CRYPTO LIBRARY ===>/usr/local/lib/libcryptopp.a
-- MY COMMON LIBRARY ===>/home/myself/dev/common/lib/libcommon.a
So, the libraries are being found. Here are the errors I'm getting on compilation. I've cropped some errors otherwise I wouldn't be able to post, but seen that all crypto calls are undefined:
...
[ 64%] Linking CXX executable hwinfo
../../../lib/libcommon.a(Encryptor.cpp.o): In function `common::Encryptor::encrypt(std::string)':
Encryptor.cpp:(.text+0x2a6): undefined reference to `CryptoPP::CipherModeFinalTemplate_ExternalCipher<CryptoPP::CBC_Encryption>::CipherModeFinalTemplate_ExternalCipher(CryptoPP::BlockCipher&, unsigned char const*, int)'
Encryptor.cpp:(.text+0x2c5): undefined reference to `CryptoPP::StringSinkTemplate<std::string>::StringSinkTemplate(std::string&)'
Encryptor.cpp:(.text+0x2ed): undefined reference to `CryptoPP::StreamTransformationFilter::StreamTransformationFilter(CryptoPP::StreamTransformation&, CryptoPP::BufferedTransformation*, CryptoPP::BlockPaddingSchemeDef::BlockPaddingScheme, bool)'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `common::Encryptor::decrypt(std::string)':
Encryptor.cpp:(.text+0x477): undefined reference to `CryptoPP::CipherModeFinalTemplate_ExternalCipher<CryptoPP::CBC_Decryption>::CipherModeFinalTemplate_ExternalCipher(CryptoPP::BlockCipher&, unsigned char const*, int)'
Encryptor.cpp:(.text+0x4a5): undefined reference to `CryptoPP::StringSinkTemplate<std::string>::StringSinkTemplate(std::string&)'
Encryptor.cpp:(.text+0x4cd): undefined reference to `CryptoPP::StreamTransformationFilter::StreamTransformationFilter(CryptoPP::StreamTransformation&, CryptoPP::BufferedTransformation*, CryptoPP::BlockPaddingSchemeDef::BlockPaddingScheme, bool)'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::SimpleKeyingInterface::~SimpleKeyingInterface()':
Encryptor.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceD2Ev[_ZN8CryptoPP21SimpleKeyingInterfaceD5Ev]+0x13): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BufferedTransformation::~BufferedTransformation()':
Encryptor.cpp:(.text._ZN8CryptoPP22BufferedTransformationD2Ev[_ZN8CryptoPP22BufferedTransformationD5Ev]+0x13): undefined reference to `vtable for CryptoPP::BufferedTransformation'
Encryptor.cpp:(.text._ZN8CryptoPP22BufferedTransformationD2Ev[_ZN8CryptoPP22BufferedTransformationD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::BufferedTransformation'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::SimpleKeyingInterface::SimpleKeyingInterface()':
Encryptor.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceC2Ev[_ZN8CryptoPP21SimpleKeyingInterfaceC5Ev]+0xf): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::StreamTransformation::~StreamTransformation()':
Encryptor.cpp:(.text._ZN8CryptoPP20StreamTransformationD2Ev[_ZN8CryptoPP20StreamTransformationD5Ev]+0x13): undefined reference to `vtable for CryptoPP::StreamTransformation'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BlockOrientedCipherModeBase::Resynchronize(unsigned char const*, int)':
Encryptor.cpp:(.text._ZN8CryptoPP27BlockOrientedCipherModeBase13ResynchronizeEPKhi[_ZN8CryptoPP27BlockOrientedCipherModeBase13ResynchronizeEPKhi]+0x23): undefined reference to `CryptoPP::SimpleKeyingInterface::ThrowIfInvalidIVLength(int)'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::Filter::~Filter()':
Encryptor.cpp:(.text._ZN8CryptoPP6FilterD2Ev[_ZN8CryptoPP6FilterD5Ev]+0x13): undefined reference to `vtable for CryptoPP::Filter'
Encryptor.cpp:(.text._ZN8CryptoPP6FilterD2Ev[_ZN8CryptoPP6FilterD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::Filter'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::FilterWithBufferedInput::~FilterWithBufferedInput()':
Encryptor.cpp:(.text._ZN8CryptoPP23FilterWithBufferedInputD2Ev[_ZN8CryptoPP23FilterWithBufferedInputD5Ev]+0x13): undefined reference to `vtable for CryptoPP::FilterWithBufferedInput'
Encryptor.cpp:(.text._ZN8CryptoPP23FilterWithBufferedInputD2Ev[_ZN8CryptoPP23FilterWithBufferedInputD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::FilterWithBufferedInput'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::~SecBlock()':
Encryptor.cpp:(.text._ZN8CryptoPP8SecBlockIhNS_20AllocatorWithCleanupIhLb0EEEED2Ev[_ZN8CryptoPP8SecBlockIhNS_20AllocatorWithCleanupIhLb0EEEED5Ev]+0x27): undefined reference to `CryptoPP::AllocatorWithCleanup<unsigned char, false>::deallocate(void*, unsigned long)'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::New(unsigned long)':
Encryptor.cpp:(.text._ZN8CryptoPP8SecBlockIhNS_20AllocatorWithCleanupIhLb0EEEE3NewEm[_ZN8CryptoPP8SecBlockIhNS_20AllocatorWithCleanupIhLb0EEEE3NewEm]+0x32): undefined reference to `CryptoPP::AllocatorWithCleanup<unsigned char, false>::reallocate(unsigned char*, unsigned long, unsigned long, bool)'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BlockTransformation::BlockTransformation()':
Encryptor.cpp:(.text._ZN8CryptoPP19BlockTransformationC2Ev[_ZN8CryptoPP19BlockTransformationC5Ev]+0x19): undefined reference to `CryptoPP::Algorithm::Algorithm(bool)'
Encryptor.cpp:(.text._ZN8CryptoPP19BlockTransformationC2Ev[_ZN8CryptoPP19BlockTransformationC5Ev]+0x24): undefined reference to `vtable for CryptoPP::BlockTransformation'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BlockTransformation::~BlockTransformation()':
Encryptor.cpp:(.text._ZN8CryptoPP19BlockTransformationD2Ev[_ZN8CryptoPP19BlockTransformationD5Ev]+0x13): undefined reference to `vtable for CryptoPP::BlockTransformation'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::Rijndael::Base::Base()':
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2Ev[_ZN8CryptoPP8Rijndael4BaseC5Ev]+0x20): undefined reference to `vtable for CryptoPP::Rijndael::Base'
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2Ev[_ZN8CryptoPP8Rijndael4BaseC5Ev]+0x2c): undefined reference to `vtable for CryptoPP::Rijndael::Base'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::Rijndael::Base::~Base()':
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael4BaseD2Ev[_ZN8CryptoPP8Rijndael4BaseD5Ev]+0x13): undefined reference to `vtable for CryptoPP::Rijndael::Base'
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael4BaseD2Ev[_ZN8CryptoPP8Rijndael4BaseD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::Rijndael::Base'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::Rijndael::Enc::Enc()':
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2Ev[_ZN8CryptoPP8Rijndael3EncC5Ev]+0x1f): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2Ev[_ZN8CryptoPP8Rijndael3EncC5Ev]+0x2b): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::Rijndael::Enc::~Enc()':
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3EncD2Ev[_ZN8CryptoPP8Rijndael3EncD5Ev]+0x13): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3EncD2Ev[_ZN8CryptoPP8Rijndael3EncD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>::BlockCipherFinal(unsigned char const*, unsigned long)':
Encryptor.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC2EPKhm[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC5EPKhm]+0x3b): undefined reference to `CryptoPP::g_nullNameValuePairs'
Encryptor.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC2EPKhm[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC5EPKhm]+0x4f): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BlockOrientedCipherModeBase::~BlockOrientedCipherModeBase()':
Encryptor.cpp:(.text._ZN8CryptoPP27BlockOrientedCipherModeBaseD2Ev[_ZN8CryptoPP27BlockOrientedCipherModeBaseD5Ev]+0x13): undefined reference to `vtable for CryptoPP::BlockOrientedCipherModeBase'
Encryptor.cpp:(.text._ZN8CryptoPP27BlockOrientedCipherModeBaseD2Ev[_ZN8CryptoPP27BlockOrientedCipherModeBaseD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::BlockOrientedCipherModeBase'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::CBC_Encryption::~CBC_Encryption()':
Encryptor.cpp:(.text._ZN8CryptoPP14CBC_EncryptionD2Ev[_ZN8CryptoPP14CBC_EncryptionD5Ev]+0x13): undefined reference to `vtable for CryptoPP::CBC_Encryption'
Encryptor.cpp:(.text._ZN8CryptoPP14CBC_EncryptionD2Ev[_ZN8CryptoPP14CBC_EncryptionD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::CBC_Encryption'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::Rijndael::Dec::Dec()':
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3DecC2Ev[_ZN8CryptoPP8Rijndael3DecC5Ev]+0x1f): undefined reference to `vtable for CryptoPP::Rijndael::Dec'
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3DecC2Ev[_ZN8CryptoPP8Rijndael3DecC5Ev]+0x2b): undefined reference to `vtable for CryptoPP::Rijndael::Dec'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::Rijndael::Dec::~Dec()':
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3DecD2Ev[_ZN8CryptoPP8Rijndael3DecD5Ev]+0x13): undefined reference to `vtable for CryptoPP::Rijndael::Dec'
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3DecD2Ev[_ZN8CryptoPP8Rijndael3DecD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::Rijndael::Dec'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec>::BlockCipherFinal(unsigned char const*, unsigned long)':
Encryptor.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEC2EPKhm[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEC5EPKhm]+0x3b): undefined reference to `CryptoPP::g_nullNameValuePairs'
Encryptor.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEC2EPKhm[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEC5EPKhm]+0x4f): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::CBC_Decryption::~CBC_Decryption()':
Encryptor.cpp:(.text._ZN8CryptoPP14CBC_DecryptionD2Ev[_ZN8CryptoPP14CBC_DecryptionD5Ev]+0x13): undefined reference to `vtable for CryptoPP::CBC_Decryption'
Encryptor.cpp:(.text._ZN8CryptoPP14CBC_DecryptionD2Ev[_ZN8CryptoPP14CBC_DecryptionD5Ev]+0x1f): undefined reference to `vtable for CryptoPP::CBC_Decryption'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::AllocatorWithCleanup<unsigned char, true>::allocate(unsigned long, void const*)':
Encryptor.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEmPKv[_ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEmPKv]+0x40): undefined reference to `CryptoPP::AlignedAllocate(unsigned long)'
Encryptor.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEmPKv[_ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEmPKv]+0x4e): undefined reference to `CryptoPP::UnalignedAllocate(unsigned long)'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::AllocatorWithCleanup<unsigned char, true>::deallocate(void*, unsigned long)':
Encryptor.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvm[_ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvm]+0x39): undefined reference to `CryptoPP::AlignedDeallocate(void*)'
Encryptor.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvm[_ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvm]+0x47): undefined reference to `CryptoPP::UnalignedDeallocate(void*)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE]+0x48): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE]+0x78): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE]+0x88): undefined reference to `CryptoPP::Rijndael::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE]+0xa0): undefined reference to `CryptoPP::Rijndael::Dec::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE]+0xa8): undefined reference to `CryptoPP::Rijndael::Dec::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE]+0xf0): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Dec::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE]+0x100): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEE]+0x120): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Dec::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE]+0x48): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE]+0x78): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE]+0x88): undefined reference to `CryptoPP::Rijndael::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE]+0xa0): undefined reference to `CryptoPP::Rijndael::Dec::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE]+0xa8): undefined reference to `CryptoPP::Rijndael::Dec::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE]+0xe8): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Dec::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE]+0xf8): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEES4_EE]+0x118): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Dec::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE]+0x48): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE]+0x78): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE]+0x88): undefined reference to `CryptoPP::Rijndael::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE]+0xa0): undefined reference to `CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE]+0xa8): undefined reference to `CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE]+0xf0): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE]+0x100): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE]+0x120): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE]+0x48): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE]+0x78): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE]+0x88): undefined reference to `CryptoPP::Rijndael::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE]+0xa0): undefined reference to `CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE]+0xa8): undefined reference to `CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE]+0xe8): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE]+0xf8): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE]+0x118): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
Encryptor.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2ERKS1_[_ZN8CryptoPP8Rijndael3EncC5ERKS1_]+0x36): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
collect2: error: ld returned 1 exit status
cpp/hwinfo/CMakeFiles/hwinfo.dir/build.make:85: recipe for target 'cpp/hwinfo/hwinfo' failed
make[2]: *** [cpp/hwinfo/hwinfo] Error 1
CMakeFiles/Makefile2:167: recipe for target 'cpp/hwinfo/CMakeFiles/hwinfo.dir/all' failed
make[1]: *** [cpp/hwinfo/CMakeFiles/hwinfo.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
I've no idea of what is causing that.
Why is my Crypto++ library not being loaded to resolve the symbols as they are explicitly declared on my Cmake file?
EDIT: After inverting the libraries order, as follows:
target_link_libraries(hwinfo ${LIBCOMMON} ${LIBCRYPTOPP})
I'm getting fewer error messages, but still undefined symbols as follows:
[71%] Linking CXX executable hwinfo
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>::BlockCipherFinal(unsigned char const*, unsigned long)':
Encryptor.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC2EPKhm[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC5EPKhm]+0x3b): undefined reference to `CryptoPP::g_nullNameValuePairs'
../../../lib/libcommon.a(Encryptor.cpp.o): In function `CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec>::BlockCipherFinal(unsigned char const*, unsigned long)':
Encryptor.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEC2EPKhm[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE1ENS_8Rijndael3DecEEC5EPKhm]+0x3b): undefined reference to `CryptoPP::g_nullNameValuePairs'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP12CBC_ModeBaseE[_ZTVN8CryptoPP12CBC_ModeBaseE]+0x128): undefined reference to `CryptoPP::StreamTransformation::ProcessLastBlock(unsigned char*, unsigned char const*, unsigned long)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP14CipherModeBaseE[_ZTVN8CryptoPP14CipherModeBaseE]+0x100): undefined reference to `CryptoPP::StreamTransformation::ProcessLastBlock(unsigned char*, unsigned char const*, unsigned long)'
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP15SymmetricCipherE[_ZTVN8CryptoPP15SymmetricCipherE]+0xe8): undefined reference to `CryptoPP::StreamTransformation::ProcessLastBlock(unsigned char*, unsigned char const*, unsigned long)'
collect2: error: ld returned 1 exit status
cpp/hwinfo/CMakeFiles/hwinfo.dir/build.make:85: recipe for target 'cpp/hwinfo/hwinfo' failed
make[2]: *** [cpp/hwinfo/hwinfo] Error 1
CMakeFiles/Makefile2:167: recipe for target 'cpp/hwinfo/CMakeFiles/hwinfo.dir/all' failed
make[1]: *** [cpp/hwinfo/CMakeFiles/hwinfo.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Order matters! If library A depends on library B, then library A must come before library B when linking. So the simple solution is to change the order in which you link your "common" library and the cryptopp library.
Also note that since you apparently create a static library, you don't actually link anything when creating the library. So the target_link_libraries command is useless for the library, as your project is currently set up.
My suggestion is that you link the two CMakeLists.txt files together, so the main executable CMakeLists.txt file uses the library CMakeLists.txt file (for example using the add_subdirectory command). Then you first of all don't need to install the library, and you could make COMMON depend on CRYPTOPP and CMake would link in correct order.

Based on this:
I have a project that depends on cryptopp on Debian 8.10
And this:
../../../lib/libcommon.a(Encryptor.cpp.o):(.rodata._ZTVN8CryptoPP15SymmetricCipherE[_ZTVN8CryptoPP15SymmetricCipherE]+0xe8):
undefined reference to `CryptoPP::StreamTransformation::ProcessLastBlock(unsigned char*, unsigned char const*, unsigned long)'
collect2: error: ld returned 1 exit status
And this:
-- CRYPTO LIBRARY ===>/usr/local/lib/libcryptopp.a
It looks like you have two copies of the Crypo++ library and you are mixing and matching them.
I think the easiest/best fix is to run the following commands. They remove your copy so you use Debian's copy.
rm -rf /usr/local/include/cryptopp
rm -rf /usr/local/lib/*cryptopp*
rm -rf /usr/local/bin/cryptest*
rm -rf /usr/local/share/cryptopp
The reason I think its a problem is because ProcessLastBlock now returns a size_t. That change happened at Crypto++ 6.0. The change was needed for authenticated encryption modes like OCB. OCB handles padding of the last block itself, so it needed a way to specify how much of the provided buffer was used.
Crypto++ 5.6.3 and earlier used ProcessLastBlock that returned void. There was a tight coupling of a block cipher mode and an explicit requirement the last block was always a full block size. But like I said, that did not hold as we started adding additional modes of operation.
Also see the head notes in filters.cpp and the function StreamTransformationFilter::LastPut:
// This block is new to StreamTransformationFilter. It somewhat of a hack and was added
// for OCB mode; see GitHub Issue 515. The rub with OCB is, its a block cipher and the
// last block size can be 0. However, "last block = 0" is not the 0 predacted in the
// original code. In the orginal code 0 means "nothing special" so DEFAULT_PADDING is
// applied. OCB's 0 literally means a final block size can be 0 or non-0; and no padding
// is needed in either case because OCB has its own scheme (see handling of P_* and A_*).
// Stream ciphers have policy objects to convey how to operate the cipher. The Crypto++
// framework operates well when MinLastBlockSize() is 1. However, it did not appear to
// cover the OCB case either because we can't stream OCB. It needs full block sizes. In
// response we hacked a IsLastBlockSpecial(). When true StreamTransformationFilter
// defers to the mode for processing of the last block.
// The behavior supplied when IsLastBlockSpecial() will likely have to evolve to capture
// more complex cases from different authenc modes. I suspect it will have to change
// from a simple bool to something that conveys more information, like "last block
// no padding" or "custom padding applied by cipher".
// In some respect we have already hit the need for more information. For example, OCB
// calculates the checksum on the cipher text at the same time, so we don't need the
// disjoint behavior of calling "EncryptBlock" followed by a separate "AuthenticateBlock".
// Additional information may allow us to avoid the two spearate calls.
And to reiterate from Linux | Distribution Package on the wiki:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.10 (jessie)
Release: 8.10
Codename: jessie
$ apt-cache search libcrypto++
...
libcrypto++-dev - General purpose cryptographic library - C++ development
libcrypto++-doc - General purpose cryptographic library - documentation
libcrypto++-utils - General purpose cryptographic library - utilities and data files
libcrypto++9 - General purpose cryptographic library - shared library
libcrypto++9-dbg - General purpose cryptographic library - debug symbols
So you need libcrypto++9, libcrypto++-dev and possibly libcrypto++9-dbg.

Related

Error in compiling a sfml c++ code using protocol buffers

I downloaded some example protobuff codes and sfml-networking but i cant compile the files and i dont what's wrong i definitly installed "libprotobuf-dev" and "protobuf-compiler" and also the code seem to run ok on other Pcs but when i use command make in terminal i get this error
this is the repository i cloned the example from :
https://github.com/An-Alone-Cow/schat
please help me i tried every thing
i also reinstalled all protobuff things several times and even installed manually from github repository provided by google
this is the error massege i get
g++ main.o messages.pb.o -L/usr/SFML-2.5.1/lib/ -lprotobuf -lsfml-network -lsfml-system -o run
main.o: In function `google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()':
main.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0x7): undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
messages.pb.o: In function `Message* google::protobuf::Arena::CreateMaybeMessage<Message>(google::protobuf::Arena*)':
messages.pb.cc:(.text+0x177a): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text+0x1799): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o: In function `__static_initialization_and_destruction_0(int, int)':
messages.pb.cc:(.text+0x1855): undefined reference to `google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)'
messages.pb.o: In function `google::protobuf::Arena::AllocHook(std::type_info const*, unsigned long) const':
messages.pb.cc:(.text._ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom[_ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom]+0x3d): undefined reference to `google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
messages.pb.o: In function `google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x22f): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x24e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o: In function `google::protobuf::internal::InitSCC(google::protobuf::internal::SCCInfoBase*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE[_ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE]+0x4d): undefined reference to `google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*)'
messages.pb.o: In function `google::protobuf::internal::OnShutdownDestroyMessage(void const*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x16): undefined reference to `google::protobuf::internal::DestroyMessage(void const*)'
messages.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x1e): undefined reference to `google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*)'
messages.pb.o: In function `Message::GetMetadataStatic()':
messages.pb.cc:(.text._ZN7Message17GetMetadataStaticEv[_ZN7Message17GetMetadataStaticEv]+0xc): undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*)'
messages.pb.o: In function `google::protobuf::internal::InternalMetadataWithArenaBase<google::protobuf::UnknownFieldSet, google::protobuf::internal::InternalMetadataWithArena>::mutable_unknown_fields_slow()':
messages.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x15e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x17a): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o:(.data.rel.ro._ZTV7Message[_ZTV7Message]+0xb8): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
collect2: error: ld returned 1 exit status
Makefile:2: recipe for target 'run' failed
make: *** [run] Error 1
[1]: https://github.com/An-Alone-Cow/schat

Unable to link Crypto++ Speck algorithm due to undefined references

I'm trying to utilize Crypto++'s Simon and Speck implementations for a research project, but I currently cannot compile and link the example code provided on its wiki page.
Following the instructions from the Crypto++ wiki, I was able to build the library and run all of their test suites to completion. I have also been able to run example AES code from the same wiki. The compilation errors only come when I try to invoke Simon or Speck.
To compile and link the file I am using g++ speck_test.cpp -lcryptopp.
Here is the program provided on the Crypto++ Speck wiki. I added include statements and scope resolutions where I believed necessary.
#include <iostream>
#include <iomanip>
#include "cryptopp/modes.h"
#include "cryptopp/speck.h"
#include "cryptopp/filters.h"
int main(int argc, char* argv[]) {
CryptoPP::SPECK128::Encryption speck;
std::cout << "StaticAlgorithmName: " << speck.StaticAlgorithmName() << std::endl;
std::cout << "AlgorithmName (unkeyed): " << speck.AlgorithmName() << std::endl;
CryptoPP::byte key[CryptoPP::SPECK128::DEFAULT_KEYLENGTH] = {};
speck.SetKey(key, sizeof(key));
std::cout << "AlgorithmName (keyed): " << speck.AlgorithmName() << std::endl;
return 0;
}
Expected output of this program according to the wiki is
StaticAlgorithmName: SPECK-128
AlgorithmName (unkeyed): SPECK-128
AlgorithmName (keyed): SPECK-128(128)
however, I am receiving the following error from the compiler:
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Base::Base()':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2Ev[_ZN8CryptoPP8SPECK1284BaseC5Ev]+0x2c): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2Ev[_ZN8CryptoPP8SPECK1284BaseC5Ev]+0x3a): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2Ev[_ZN8CryptoPP8SPECK1284BaseC5Ev]+0x49): undefined reference to `vtable for CryptoPP::SPECK128::Base'
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Base::~Base()':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseD2Ev[_ZN8CryptoPP8SPECK1284BaseD5Ev]+0xf): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseD2Ev[_ZN8CryptoPP8SPECK1284BaseD5Ev]+0x1d): undefined reference to `vtable for CryptoPP::SPECK128::Base'
/tmp/ccD02cM7.o:speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseD2Ev[_ZN8CryptoPP8SPECK1284BaseD5Ev]+0x2c): more undefined references to `vtable for CryptoPP::SPECK128::Base' follow
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Enc::Enc()':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2Ev[_ZN8CryptoPP8SPECK1283EncC5Ev]+0x1b): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2Ev[_ZN8CryptoPP8SPECK1283EncC5Ev]+0x29): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2Ev[_ZN8CryptoPP8SPECK1283EncC5Ev]+0x38): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Enc::~Enc()':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncD2Ev[_ZN8CryptoPP8SPECK1283EncD5Ev]+0xf): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncD2Ev[_ZN8CryptoPP8SPECK1283EncD5Ev]+0x1d): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
/tmp/ccD02cM7.o:speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncD2Ev[_ZN8CryptoPP8SPECK1283EncD5Ev]+0x2c): more undefined references to `vtable for CryptoPP::SPECK128::Enc' follow
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x28): undefined reference to `CryptoPP::SPECK128::Base::AlgorithmProvider[abi:cxx11]() const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x30): undefined reference to `CryptoPP::SPECK128::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x38): undefined reference to `CryptoPP::SPECK128::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x40): undefined reference to `CryptoPP::SPECK128::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0xe0): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x128): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Base::AlgorithmProvider[abi:cxx11]() const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x130): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x160): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x28): undefined reference to `CryptoPP::SPECK128::Base::AlgorithmProvider[abi:cxx11]() const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x30): undefined reference to `CryptoPP::SPECK128::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x38): undefined reference to `CryptoPP::SPECK128::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x40): undefined reference to `CryptoPP::SPECK128::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0xd8): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x120): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Base::AlgorithmProvider[abi:cxx11]() const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x128): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x158): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTIN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTIN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x10): undefined reference to `typeinfo for CryptoPP::SPECK128::Enc'
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Base::Base(CryptoPP::SPECK128::Base const&)':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2ERKS1_[_ZN8CryptoPP8SPECK1284BaseC5ERKS1_]+0x41): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2ERKS1_[_ZN8CryptoPP8SPECK1284BaseC5ERKS1_]+0x4f): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2ERKS1_[_ZN8CryptoPP8SPECK1284BaseC5ERKS1_]+0x5e): undefined reference to `vtable for CryptoPP::SPECK128::Base'
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Enc::Enc(CryptoPP::SPECK128::Enc const&)':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2ERKS1_[_ZN8CryptoPP8SPECK1283EncC5ERKS1_]+0x26): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2ERKS1_[_ZN8CryptoPP8SPECK1283EncC5ERKS1_]+0x34): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2ERKS1_[_ZN8CryptoPP8SPECK1283EncC5ERKS1_]+0x43): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
collect2: error: ld returned 1 exit status
Any help would be very appreciated!
As dave pointed out, the error was arose from the compiler being unable to find CryptoPP.
To fix this, I had to set the LD_LIBRARY_PATH environment variable on Ubuntu to include the path to the library. Then, I had to alter my compiler command to compile my file first, then link the library second, i.e.
g++ -o test.exe speck_test.cpp -L<path-to-cryptopp> -lcryptopp
rather than
g++ -L<path-to-cryptopp> -lcryptopp -o test.exe speck_test.cpp, which was failing.

Using Crypto++ in Clion IDE

I have some problem with compile correct application in fresh-installed Clion IDE. Earlier I used Code::Blocks and all compiling successfully. Project use pthread and Crypto++ library. I'm already have them installed on my Ubuntu 15.04. And compile Clion project with -pthread flag. But it can't find crypto++ library. How to fix this?
My CMake file:
cmake_minimum_required(VERSION 3.3)
project(Chat)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
set(SOURCE_FILES
include/Chat.h
include/Checker.h
include/Client.h
include/DataTransferingInterface.h
include/EncryptorDES.h
include/EncryptorRSA.h
include/Logger.h
include/OwnerClientInterface.h
include/OwnerServerInterface.h
include/Parser.h
include/SecureChat.h
include/Server.h
src/Chat.cpp
src/Checker.cpp
src/Client.cpp
src/DataTransferingInterface.cpp
src/EncryptorDES.cpp
src/EncryptorRSA.cpp
src/Logger.cpp
src/OwnerClientInterface.cpp
src/OwnerServerInterface.cpp
src/Parser.cpp
src/SecureChat.cpp
src/Server.cpp
main.cpp)
add_executable(Chat ${SOURCE_FILES})
Compile errors:
/usr/include/cryptopp/integer.h:26: undefined reference to `vtable for CryptoPP::Integer'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::AbstractRing<CryptoPP::Integer>::MultiplicativeGroupT::~MultiplicativeGroupT()':
/usr/include/cryptopp/algebra.h:70: undefined reference to `vtable for CryptoPP::AbstractRing<CryptoPP::Integer>::MultiplicativeGroupT'
/usr/include/cryptopp/algebra.h:70: undefined reference to `CryptoPP::AbstractGroup<CryptoPP::Integer>::~AbstractGroup()'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::FileStore::~FileStore()':
/usr/include/cryptopp/files.h:14: undefined reference to `vtable for CryptoPP::FileStore'
/usr/include/cryptopp/files.h:14: undefined reference to `vtable for CryptoPP::FileStore'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::FileSink::~FileSink()':
/usr/include/cryptopp/files.h:77: undefined reference to `vtable for CryptoPP::FileSink'
/usr/include/cryptopp/files.h:77: undefined reference to `vtable for CryptoPP::FileSink'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::HMAC_Base::~HMAC_Base()':
/usr/include/cryptopp/hmac.h:12: undefined reference to `vtable for CryptoPP::HMAC_Base'
/usr/include/cryptopp/hmac.h:12: undefined reference to `vtable for CryptoPP::HMAC_Base'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::AlgorithmParametersTemplate<char const*>::AssignValue(char const*, std::type_info const&, void*) const':
/usr/include/cryptopp/algparam.h:313: undefined reference to `CryptoPP::g_pAssignIntToInteger'
/usr/include/cryptopp/algparam.h:313: undefined reference to `CryptoPP::g_pAssignIntToInteger'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_EncryptorBase<CryptoPP::ECPPoint>::Encrypt(CryptoPP::RandomNumberGenerator&, unsigned char const*, unsigned long, unsigned char*, CryptoPP::NameValuePairs const&) const':
/usr/include/cryptopp/integer.h:118: undefined reference to `CryptoPP::Integer::One()'
/usr/include/cryptopp/integer.h:118: undefined reference to `CryptoPP::Integer::Zero()'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_EncryptorBase<CryptoPP::ECPPoint>::Encrypt(CryptoPP::RandomNumberGenerator&, unsigned char const*, unsigned long, unsigned char*, CryptoPP::NameValuePairs const&) const':
/usr/include/cryptopp/pubkey.h:1228: undefined reference to `CryptoPP::Integer::One()'
/usr/include/cryptopp/pubkey.h:1228: undefined reference to `CryptoPP::Integer::Integer(CryptoPP::RandomNumberGenerator&, CryptoPP::Integer const&, CryptoPP::Integer const&, CryptoPP::Integer::RandomNumberType, CryptoPP::Integer const&, CryptoPP::Integer const&)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::SourceTemplate<CryptoPP::FileStore>::Pump2(unsigned long long&, bool)':
/usr/include/cryptopp/filters.h:763: undefined reference to `CryptoPP::DEFAULT_CHANNEL'
/usr/include/cryptopp/filters.h:763: undefined reference to `CryptoPP::FileStore::TransferTo2(CryptoPP::BufferedTransformation&, unsigned long long&, std::string const&, bool)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::SourceTemplate<CryptoPP::FileStore>::PumpMessages2(unsigned int&, bool)':
/usr/include/cryptopp/filters.h:765: undefined reference to `CryptoPP::DEFAULT_CHANNEL'
/usr/include/cryptopp/filters.h:765: undefined reference to `CryptoPP::BufferedTransformation::TransferMessagesTo2(CryptoPP::BufferedTransformation&, unsigned int&, std::string const&, bool)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::SourceTemplate<CryptoPP::FileStore>::PumpAll2(bool)':
/usr/include/cryptopp/filters.h:767: undefined reference to `CryptoPP::DEFAULT_CHANNEL'
/usr/include/cryptopp/filters.h:767: undefined reference to `CryptoPP::BufferedTransformation::TransferAllTo2(CryptoPP::BufferedTransformation&, std::string const&, bool)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::SourceTemplate<CryptoPP::FileStore>::SourceExhausted() const':
/usr/include/cryptopp/filters.h:769: undefined reference to `CryptoPP::BufferedTransformation::AnyRetrievable() const'
/usr/include/cryptopp/filters.h:769: undefined reference to `CryptoPP::BufferedTransformation::AnyMessages() const'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_EncryptionAlgorithm_Xor<CryptoPP::HMAC<CryptoPP::SHA1>, false>::SymmetricEncrypt(CryptoPP::RandomNumberGenerator&, unsigned char const*, unsigned char const*, unsigned long, unsigned char*, CryptoPP::NameValuePairs const&) const':
/usr/include/cryptopp/gfpcrypt.h:439: undefined reference to `CryptoPP::xorbuf(unsigned char*, unsigned char const*, unsigned char const*, unsigned long)'
/usr/include/cryptopp/gfpcrypt.h:441: undefined reference to `CryptoPP::HMAC_Base::Update(unsigned char const*, unsigned long)'
/usr/include/cryptopp/gfpcrypt.h:442: undefined reference to `CryptoPP::HMAC_Base::Update(unsigned char const*, unsigned long)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_EncryptionAlgorithm_Xor<CryptoPP::HMAC<CryptoPP::SHA1>, false>::SymmetricDecrypt(unsigned char const*, unsigned char const*, unsigned long, unsigned char*, CryptoPP::NameValuePairs const&) const':
/usr/include/cryptopp/gfpcrypt.h:470: undefined reference to `CryptoPP::HMAC_Base::Update(unsigned char const*, unsigned long)'
/usr/include/cryptopp/gfpcrypt.h:471: undefined reference to `CryptoPP::HMAC_Base::Update(unsigned char const*, unsigned long)'
/usr/include/cryptopp/gfpcrypt.h:481: undefined reference to `CryptoPP::xorbuf(unsigned char*, unsigned char const*, unsigned char const*, unsigned long)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_KeyAgreementAlgorithm_DH<CryptoPP::ECPPoint, CryptoPP::EnumToType<CryptoPP::CofactorMultiplicationOption, 0> >::AgreeWithEphemeralPrivateKey(CryptoPP::DL_GroupParameters<CryptoPP::ECPPoint> const&, CryptoPP::DL_FixedBasePrecomputation<CryptoPP::ECPPoint> const&, CryptoPP::Integer const&) const':
/usr/include/cryptopp/pubkey.h:1445: undefined reference to `CryptoPP::Integer::Integer(CryptoPP::Integer const&)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_KeyAgreementAlgorithm_DH<CryptoPP::ECPPoint, CryptoPP::EnumToType<CryptoPP::CofactorMultiplicationOption, 0> >::AgreeWithStaticPrivateKey(CryptoPP::DL_GroupParameters<CryptoPP::ECPPoint> const&, CryptoPP::ECPPoint const&, bool, CryptoPP::Integer const&) const':
/usr/include/cryptopp/pubkey.h:1473: undefined reference to `CryptoPP::Integer::Integer(CryptoPP::Integer const&)'
/usr/include/cryptopp/pubkey.h:1473: undefined reference to `CryptoPP::Integer::Integer(CryptoPP::Integer const&)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::HMAC<CryptoPP::SHA1>::HMAC(unsigned char const*, unsigned long)':
/usr/include/cryptopp/hmac.h:48: undefined reference to `CryptoPP::g_nullNameValuePairs'
/usr/include/cryptopp/hmac.h:48: undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::P1363_KDF2<CryptoPP::SHA1>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long)':
/usr/include/cryptopp/pubkey.h:506: undefined reference to `CryptoPP::P1363_MGF1KDF2_Common(CryptoPP::HashTransformation&, unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, bool, unsigned int)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::IteratedHashWithStaticTransform<unsigned int, CryptoPP::EnumToType<CryptoPP::ByteOrder, 1>, 64u, 20u, CryptoPP::SHA1, 0u, false>::Init()':
/usr/include/cryptopp/iterhash.h:90: undefined reference to `CryptoPP::SHA1::InitState(unsigned int*)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o:(.rodata._ZTIN8CryptoPP16IteratedHashBaseIjNS_18HashTransformationEEE[_ZTIN8CryptoPP16IteratedHashBaseIjNS_18HashTransformationEEE]+0x10): undefined reference to `typeinfo for CryptoPP::HashTransformation'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o:(.rodata._ZTIN8CryptoPP25SimpleKeyingInterfaceImplINS_9HMAC_BaseENS_4HMACINS_4SHA1EEEEE[_ZTIN8CryptoPP25SimpleKeyingInterfaceImplINS_9HMAC_BaseENS_4HMACINS_4SHA1EEEEE]+0x10): undefined reference to `typeinfo for CryptoPP::HMAC_Base'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::HashTransformation::HashTransformation(CryptoPP::HashTransformation const&)':
/usr/include/cryptopp/cryptlib.h:531: undefined reference to `vtable for CryptoPP::HashTransformation'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::IteratedHashWithStaticTransform<unsigned int, CryptoPP::EnumToType<CryptoPP::ByteOrder, 1>, 64u, 20u, CryptoPP::SHA1, 0u, false>::HashEndianCorrectedBlock(unsigned int const*)':
/usr/include/cryptopp/iterhash.h:89: undefined reference to `CryptoPP::SHA1::Transform(unsigned int*, unsigned int const*)'
collect2: error: ld returned 1 exit status
CMakeFiles/Chat.dir/build.make:406: recipe for target 'Chat' failed
make[2]: *** [Chat] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Chat.dir/all' failed
make[1]: *** [CMakeFiles/Chat.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I performed the following after add_executable in my CMakeLists.txt to resolve the issue:
target_link_libraries(Chat /usr/lib/libcrypto++.a)

undefined reference errors when I add boost log dependecies

I am trying to add boost logging functionality.
But I've got a lot of errors with undefined reference.
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::~thread_specific_ptr()':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::get() const':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::reset(boost::log::v2s_mt_nt5::core::implementation::thread_data*)':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `get':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `reset':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `get':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `reset':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `~thread_specific_ptr':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(severity_level.o): In function `void boost::this_thread::at_thread_exit<boost::_bi::bind_t<boost::_bi::unspecified, boost::checked_deleter<unsigned long long>, boost::_bi::list1<boost::_bi::value<unsigned long long*> > > >(boost::_bi::bind_t<boost::_bi::unspecified, boost::checked_deleter<unsigned long long>, boost::_bi::list1<boost::_bi::value<unsigned long long*> > >)':
D:\c++\boost_1_58_0/./boost/thread/detail/thread.hpp:861: undefined reference to `boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(once_block.o): In function `boost::detail::basic_cv_list_entry::wait(boost::detail::timeout)':
D:\c++\boost_1_58_0/./boost/thread/win32/condition_variable.hpp:94: undefined reference to `boost::this_thread::interruptible_wait(void*, boost::detail::timeout)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(thread_id.o): In function `at_thread_exit<boost::log::v2s_mt_nt5::aux::this_thread::(anonymous namespace)::id_storage::deleter>':
D:\c++\boost_1_58_0/./boost/thread/detail/thread.hpp:861: undefined reference to `boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*)'
collect2.exe: error: ld returned 1 exit status
My linked libraries looks like this.
My include declarations looks like this
Also my boost include folder is located in main x86_64-w64-mingw32 include folder
Had the same error under Windows 10, Cygwin GCC setup. I had to link boost_thread separately in addition to boost_log and boost_log_setup.
-lboost_log_setup -lboost_log -lboost_thread
I was using BOOST 1.66.

How to solve compilation error when building Dlib code.?

I was tried to run sample Dlib code Using MinGW and Netbeans. But I got compilation error.
Steps Followed:
1.Downloaded Dlib package from Dlib website.
2.Include root folder(Dlib) in c++ Compiler setting and also set -std=c++11 in compiler additional flag.
3.Copy the sample from example of Dlib folder.
4.Compiled.
I got Bellow error when compiling code.Give me simple steps for executing Dlib sample code(for example face_detection_ex code in example in Dlib)
build/Debug/MinGW-Windows/main.o: In function `Z12loadIbugDataN5boost10filesystem4pathE':
D:\NetBeansProjects\SDM/main.cpp:124: undefined reference to `boost::filesystem::path::extension() const'
D:\NetBeansProjects\SDM/main.cpp:133: undefined reference to `boost::filesystem::path::replace_extension(boost::filesystem::path const&)'
build/Debug/MinGW-Windows/main.o: In function `main':
D:\NetBeansProjects\SDM/main.cpp:355: undefined reference to `boost::program_options::options_description::m_default_line_length'
D:\NetBeansProjects\SDM/main.cpp:355: undefined reference to `boost::program_options::options_description::m_default_line_length'
D:\NetBeansProjects\SDM/main.cpp:355: undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
D:\NetBeansProjects\SDM/main.cpp:358: undefined reference to `boost::program_options::options_description::add_options()'
D:\NetBeansProjects\SDM/main.cpp:358: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, char const*)'
D:\NetBeansProjects\SDM/main.cpp:360: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
D:\NetBeansProjects\SDM/main.cpp:362: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
D:\NetBeansProjects\SDM/main.cpp:365: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
D:\NetBeansProjects\SDM/main.cpp:366: undefined reference to `boost::program_options::variables_map::variables_map()'
D:\NetBeansProjects\SDM/main.cpp:367: undefined reference to `boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)'
D:\NetBeansProjects\SDM/main.cpp:370: undefined reference to `boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)'
D:\NetBeansProjects\SDM/main.cpp:373: undefined reference to `boost::program_options::notify(boost::program_options::variables_map&)'
If you are in Linux You need to add libvl.so to your Linker setting.
In a 64-bit system you may find this file in /vlfeat/bin/glnxa64/.