在Linux下生成GUID的程序,及编译错误 “uuid/uuid.h: No such file or directory” 的解决办法。
来源:互联网 发布:seo分析 编辑:程序博客网 时间:2024/05/28 18:43
在Linux下编写生成GUID的程序,如下 guid.c 文件:
#include <stdio.h>
#include <uuid/uuid.h>
void uuid2string(const uuid_t uu, char* const str) // 把uuid转成字符串。
{
int i;
for(i=0;i<16;i++)
sprintf(str+i*2, "%02X",uu[i]);
return;
}
void main()
{
int i;
char buf[200];
uuid_t uu;
uuid_generate(uu);
printf("{");
for(i=0;i<15;i++)
printf("%02X-",uu[i]);
printf("%02X}\n",uu[15]);
uuid2string(uu, buf);
printf("%s\n",buf);
return;
}
编译guid.c文件:
# gcc -o guid guid.c -luuid
如果在编译时出现错误“uuid/uuid.h: No such file or directory”,解决办法:安装 libuuid-devel 软件包。
如下直接用yum命令安装:
[root@localhost]# yum install libuuid-develLoaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* epel: mirrors.yun-idc.com
* extras: mirrors.btte.net
* updates: mirrors.btte.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package libuuid-devel.x86_64 0:2.17.2-12.14.el6 will be installed
--> Processing Dependency: libuuid = 2.17.2-12.14.el6 for package: libuuid-devel-2.17.2-12.14.el6.x86_64
--> Running transaction check
---> Package libuuid.i686 0:2.17.2-12.7.el6_3 will be updated
--> Processing Dependency: libuuid = 2.17.2-12.7.el6_3 for package: libblkid-2.17.2-12.7.el6_3.x86_64
--> Processing Dependency: libuuid = 2.17.2-12.7.el6_3 for package: util-linux-ng-2.17.2-12.7.el6_3.x86_64
---> Package libuuid.x86_64 0:2.17.2-12.7.el6_3 will be updated
---> Package libuuid.i686 0:2.17.2-12.14.el6 will be an update
---> Package libuuid.x86_64 0:2.17.2-12.14.el6 will be an update
--> Running transaction check
---> Package libblkid.x86_64 0:2.17.2-12.7.el6_3 will be updated
---> Package libblkid.x86_64 0:2.17.2-12.14.el6 will be an update
---> Package util-linux-ng.x86_64 0:2.17.2-12.7.el6_3 will be updated
---> Package util-linux-ng.x86_64 0:2.17.2-12.14.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
libuuid-devel x86_64 2.17.2-12.14.el6 base 84 k
Updating for dependencies:
libblkid x86_64 2.17.2-12.14.el6 base 115 k
libuuid i686 2.17.2-12.14.el6 base 68 k
libuuid x86_64 2.17.2-12.14.el6 base 68 k
util-linux-ng x86_64 2.17.2-12.14.el6 base 1.5 M
Transaction Summary
================================================================================
Install 1 Package(s)
Upgrade 4 Package(s)
Total download size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): libblkid-2.17.2-12.14.el6.x86_64.rpm | 115 kB 00:00
(2/5): libuuid-2.17.2-12.14.el6.i686.rpm | 68 kB 00:00
(3/5): libuuid-2.17.2-12.14.el6.x86_64.rpm | 68 kB 00:00
(4/5): libuuid-devel-2.17.2-12.14.el6.x86_64.rpm | 84 kB 00:00
(5/5): util-linux-ng-2.17.2-12.14.el6.x86_64.rpm | 1.5 MB 00:04
--------------------------------------------------------------------------------
Total 332 kB/s | 1.9 MB 00:05
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Updating : libuuid-2.17.2-12.14.el6.x86_64 1/9
Updating : libblkid-2.17.2-12.14.el6.x86_64 2/9
Updating : util-linux-ng-2.17.2-12.14.el6.x86_64 3/9
Installing : libuuid-devel-2.17.2-12.14.el6.x86_64 4/9
Updating : libuuid-2.17.2-12.14.el6.i686 5/9
Cleanup : util-linux-ng-2.17.2-12.7.el6_3.x86_64 6/9
Cleanup : libuuid-2.17.2-12.7.el6_3 7/9
Cleanup : libblkid-2.17.2-12.7.el6_3.x86_64 8/9
Cleanup : libuuid-2.17.2-12.7.el6_3 9/9
Verifying : libblkid-2.17.2-12.14.el6.x86_64 1/9
Verifying : util-linux-ng-2.17.2-12.14.el6.x86_64 2/9
Verifying : libuuid-2.17.2-12.14.el6.i686 3/9
Verifying : libuuid-2.17.2-12.14.el6.x86_64 4/9
Verifying : libuuid-devel-2.17.2-12.14.el6.x86_64 5/9
Verifying : libuuid-2.17.2-12.7.el6_3.x86_64 6/9
Verifying : libuuid-2.17.2-12.7.el6_3.i686 7/9
Verifying : util-linux-ng-2.17.2-12.7.el6_3.x86_64 8/9
Verifying : libblkid-2.17.2-12.7.el6_3.x86_64 9/9
Installed:
libuuid-devel.x86_64 0:2.17.2-12.14.el6
Dependency Updated:
libblkid.x86_64 0:2.17.2-12.14.el6 libuuid.i686 0:2.17.2-12.14.el6
libuuid.x86_64 0:2.17.2-12.14.el6 util-linux-ng.x86_64 0:2.17.2-12.14.el6
Complete!
[root@localhost]#
0 1
- 在Linux下生成GUID的程序,及编译错误 “uuid/uuid.h: No such file or directory” 的解决办法。
- 在Linux下生成GUID的程序,及编译错误 “uuid/uuid.h: No such file or directory” 的解决办法。
- Linux 错误:fatal error: uuid/uuid.h: No such file or directory
- uuid/uuid.h;No such file or directory
- uuid/uuid.h;No such file or directory
- 【centos】error: uuid/uuid.h: No such file or directory
- Archlinux 缺少<uuid/uuid.h> No such file or directory
- error: uuid/uuid.h: No such file or directory
- 64位linux下编译32位程序的错误“error: gnu/stubs-32.h: No such file or directory”
- pro*c/c++编译错误 ” error: sqlca.h: No such file or directory “ 的解决办法
- Ubuntu QT里编译显示 uuid.h no such file or directory
- Linux下出现 error: mysql.h: No such file or directory 的解决办法
- 64bit Linux下error: gnu/stubs-32.h: No such file or directory错误解决办法
- 一种编译错误的解决办法。/usr/include/linux/errno.h:4:23: fatal error: asm/errno.h: No such file or directory
- stdint.h: No such file or directory的解决办法
- 编译GCC-4.8出现的错误 —— Linux gnu/stubs-32.h: No such file or directory
- Qt安装后编译实例的错误提示“GL/gl.h: No such file or directory”
- 在VS2010下编译无法打开包括文件:“GL/glaux.h”: No such file or directory的解决
- JS获取IP、MAC和主机名的几种方法
- Oracel-性能-测试
- 解决Eclipse和MyEclipsejava.lang.OutOfMemoryError Java heap space的错误
- iOS长按手势UILongPressGestureRecognizer
- 控制CPU曲线变化
- 在Linux下生成GUID的程序,及编译错误 “uuid/uuid.h: No such file or directory” 的解决办法。
- Spring的注解配置
- ubuntu防火墙规则
- 腾讯面试题:服务器内存1G,有一个2G的文件,里面每行存着一个QQ号(5-10位数),怎么最快找出出现过最多次的QQ号。
- 做网页的网址
- oracle 常用命令
- quick-cocos2dx 如何派生一个新类
- test8-3(长方柱类)
- ubuntu 安装启动nginx, root配置