我正在尝试编译仅执行 PKCS#11 初始化但出现以下错误的示例基本代码;
gcc pkcs11_example1.c -o pk -L /usr/lib64/pkcs11/opensc-pkcs11.so
/tmp/cc8Dl0HE.o: In function `initialize':
pkcs11_example1.c:(.text+0x10): undefined reference to `C_GetFunctionList'
pkcs11_example1.c:(.text+0x2b): undefined reference to `assert'
collect2: error: ld returned 1 exit status
rpm 命令显示以下路径
rpm -ql opensc
/usr/lib64/libopensc.so.3
/usr/lib64/libopensc.so.3.0.0
/usr/lib64/libsmm-local.so.3
/usr/lib64/libsmm-local.so.3.0.0
/usr/lib64/opensc-pkcs11.so
/usr/lib64/pkcs11
/usr/lib64/pkcs11-spy.so
/usr/lib64/pkcs11/opensc-pkcs11.so
/usr/lib64/pkcs11/pkcs11-spy.so
我的代码粘贴在下面
CK_RV
initialize()
{
CK_FUNCTION_LIST_PTR pFunctionList;
CK_C_Initialize pC_Initialize;
CK_RV rv;
/* It’s OK to call C_GetFunctionList before calling
* C_Initialize */
rv = C_GetFunctionList(&pFunctionList);
assert(rv == CKR_OK);
pC_Initialize = pFunctionList -> C_Initialize;
/* Call the C_Initialize function in the library */
rv = (*pC_Initialize)(NULL_PTR);
return rv;
}
int
main(int argc, char **argv)
{
rv = initialize();
}
但仍然收到错误
undefined reference to `C_GetFunctionList'
请指导如何解决此问题