简体   繁体   English

可信平台模块 (TPM) TSS 程序编译错误

[英]Trusted Platform Module (TPM) TSS program compilation error

I am new to TPM.我是 TPM 的新手。 I want to generate random bytes using TPM via Esapi(esys) interface.我想通过 Esapi(esys) 接口使用 TPM 生成随机字节。 I am trying to initialise Esys_Initialize() .我正在尝试初始化Esys_Initialize() Below is my code:下面是我的代码:

#include "/usr/include/tss2/tss2_esys.h"

int main(){
    
    TSS2_RC rc;
    size_t tcti_size;
    TSS2_TCTI_CONTEXT *tcti_context = NULL;
    TSS2_TCTI_CONTEXT *tcti_inner = NULL;
    ESYS_CONTEXT *esys_context;
    
    TSS2_ABI_VERSION abiVersion;
    abiVersion.tssCreator=0x1;
    rc=Esys_Initialize(&esys_context, tcti_context,&abiVersion);
    
    return 0;
}

The error message is:错误信息是:

[root@Centos8_machine tpm]# gcc test.c
/tmp/ccUvOoY1.o: In function
`main': test.c:(.text+0x32): undefined reference to `Esys_Initialize'
collect2: error: ld returned 1 exit status

Can someone please tell where I am missing?有人可以告诉我在哪里失踪吗? Thanks in advance.提前致谢。

An "undefined reference" error means you are not linking against the library providing the missing symbol. “未定义的引用”错误意味着您没有链接到提供缺失符号的库。 In this case, you need to link against the library that provides the Esys_Initialize function.在这种情况下,您需要链接到提供Esys_Initialize function 的库。

If you are compiling manually, you could use:如果你手动编译,你可以使用:

$ gcc $(pkg-config --cflags --libs tss2-esys) test.c

In this case I used pkg-config --list-all | grep tss在这种情况下,我使用pkg-config --list-all | grep tss pkg-config --list-all | grep tss to find the name of this package. pkg-config --list-all | grep tss找到这个 package 的名称。 You could also inspect the needed compiler and linker flags manually:您还可以手动检查所需的编译器和 linker 标志:

$ pkg-config --cflags --libs tss2-esys
-I/usr/include/tss -ltss2-esys

If you are not building manually but need to use a build system (such as make, cmake, ...) or an IDE, then you would have to add those compiler flags ( -I/usr/include/tss ) and linker flags ( -ltss2-esys ) to your build systems.如果您不是手动构建但需要使用构建系统(例如 make、cmake、...)或 IDE,那么您必须添加这些编译器标志( -I/usr/include/tss )和 Z3175B426046347879EECE888 ( -ltss2-esys ) 到您的构建系统。 The specific steps would depend on what build system you are using.具体步骤取决于您使用的构建系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM