Linux 如何获取/使用 LibUUID?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1089741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:29:50  来源:igfitidea点击:

How do I obtain/use LibUUID?

linuxgccuuidguid

提问by Alex Black

I'm trying to replace a call to ::CoCreateGUIDso I can generate GUIDs in a C++ program on Linux.

我正在尝试替换对的调用,::CoCreateGUID以便我可以在 Linux 上的 C++ 程序中生成 GUID。

I understand that libuuidsupports this, and I've read this question.

我知道libuuid支持这一点,我已经阅读了这个问题

I'm a bit new to Ubuntu/GCC/Linux, so I've started off like this:

我对 Ubuntu/GCC/Linux 有点陌生,所以我是这样开始的:

#include <uuid/uuid.h>

And now I'm stuck! :) G++ can't find uuid.h, and I'm not sure how to get/find it.

现在我被困住了!:) G++ 找不到uuid.h,我不知道如何获取/找到它。

采纳答案by Mark Rushakoff

In Ubuntu, you can do apt-cache search libuuidto see the available packages relating to the text libuuid. Here's my output from Ubuntu 9.04:

在 Ubuntu 中,您可以apt-cache search libuuid查看与文本相关的可用包libuuid。这是我在 Ubuntu 9.04 上的输出:

$ apt-cache search libuuid
libuuid-perl - Perl extension for using UUID interfaces as defined in e2fsprogs
libuuid1 - universally unique id library
libuuid1-dbg - Debugging information for libuuid1
uuid-dev - universally unique id library - headers and static libraries
uuid-runtime - universally unique id library
libuuidm-ocaml-dev - Universally unique identifiers for OCaml

So I think the one you want is uuid-dev, and possibly uuid-runtime. Perform the command sudo apt-get install uuid-dev, and it should install the headers and libraries you need to move on past the problem you're having.

所以我认为你想要的是 uuid-dev,也可能是 uuid-runtime。执行命令sudo apt-get install uuid-dev,它应该安装你需要的头文件和库来解决你遇到的问题。

回答by hawkbat05

It's also worth mentioning that this is part of util-linux available here:

还值得一提的是,这是 util-linux 的一部分,可在此处获得:

http://www.kernel.org/pub/linux/utils/util-linux/

http://www.kernel.org/pub/linux/utils/util-linux/