I'm trying to make a static link to gcrypt lib in cmake. My cmake looks like this:
cmake_minimum_required(VERSION 3.15)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_C_COMPILER /usr/bin/gcc)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
project(testin)
set(CMAKE_CXX_STANDARD 14)
file(GLOB test
"*.h"
"*.cpp"
"*.c"
"./include/*.h"
"./src/*.c"
)
add_executable(testin ${test})
ADD_LIBRARY(libgcrypt STATIC IMPORTED)
SET_TARGET_PROPERTIES(libgcrypt PROPERTIES IMPORTED_LOCATION /usr/lib/x86_64-linux-gnu/libgcrypt.a)
target_link_libraries(testin libgcrypt)
and I've got following errors:
/usr/lib/x86_64-linux-gnu/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_err_make_from_errno':
(.text+0x46): undefined reference to `gpg_err_code_from_errno'
/usr/lib/x86_64-linux-gnu/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_error_from_errno':
(.text+0x75): undefined reference to `gpg_err_code_from_errno'
/usr/lib/x86_64-linux-gnu/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_strerror':
(.text+0x1): undefined reference to `gpg_strerror'
/usr/lib/x86_64-linux-gnu/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_strsource':
(.text+0x11): undefined reference to `gpg_strsource'
..... etc.
I tried to find on Stack what am i doin wrong and i failed to solve this problem. I'm using Clion if it is important. Can someone help me to solve this problem? Thanks in advance for your help.