自己封装了一个ASN1转tm的函数在自编辑的uxgmssl.c中,内部调用GmssL提供的俩函数接口
/**
* @brief 转换ASN1_TIME时间为tm结构
* @param[in] tm 转换后的tm结构
* @param[in] t ASN1_TIME类型的时间结构
* @return 0 转换失败
*/
int gm_asn1_time_to_tm(struct tm *tm, const ASN1_TIME *t)
{
if (t->type == V_ASN1_UTCTIME)
return asn1_utctime_to_tm(tm, t);
else if (t->type == V_ASN1_GENERALIZEDTIME)
return asn1_generalizedtime_to_tm(tm, t);
return 0;
}
其中函数 asn1_utctime_to_tm() 和 asn1_generalizedtime_to_tm() 即为GmSSL内核函数接口。GmSSL编译生成的库分别是libgmcrypto.so.1.1 和 libgmssl.so.1.1 。
通过 -lgmcrypto -lgmssl 编译uxgmssl.c 生成 uxgmssl.so。
此时启动我的主进程uxdb,去dlopen 生成的 uxgmssl.so 库,报错:uxgmssl.so : undefined symbol : asn1_utctime_to_tm
是否是因为函数是local的,所以uxgmssl.so中并不能调用(但是编译又未报任何异常)?
但还存在一个疑问,同样的代码一台centos7机器报如上所示错误,另一台centos7机器却能正常使用?是否和编译环境有关?
目前想到的办法就是拷贝GmSSL内核这俩函数实现到 uxgmssl.c 中。验证是可以解决我的问题的。
有没有其他方式解决这个报错问题?
同时希望有人可以解答我的疑问
是否是因为函数是local的,所以uxgmssl.so中并不能调用(但是编译又未报任何异常)?
但还存在一个疑问,同样的代码一台centos7机器报如上所示错误,另一台centos7机器却能正常使用?是否和编译环境有关?