最近C++开发项目中使用uuid库遇到些错误和解决方法分享:
错误描述:
函数uuid_generate没有申明
In file included from xxx.cpp:9:
xxx/uuid_util.hpp: In function ‘std::string xxx::xxx::GenerateUuid()’:
xxx/uuid_util.hpp:25:12: error: aggregate ‘uuid_t guid’ has incomplete type and cannot be defined
uuid_t guid;
^~~~
xxx/uuid_util.hpp:26:5: error: ‘uuid_generate’ was not declared in this scope
uuid_generate(reinterpret_cast<unsigned char*>(&guid));
^~~~~~~~~~~~~
xxx/uuid_util.hpp:26:5: note: suggested alternative: ‘uuid_create’
uuid_generate(reinterpret_cast<unsigned char*>(&guid));
^~~~~~~~~~~~~
uuid_create
xxx/uuid_util.hpp:27:5: error: ‘uuid_unparse’ was not declared in this scope
uuid_unparse(guid, buffer);
^~~~~~~~~~~~
xxx/uuid_util.hpp:27:5: note: suggested alternative: ‘uuid_compare’
uuid_unparse(guid, buffer);
解决方法:
需要安装libuuid-devel库, yum命令:yum -y install libuuid-devel