The method of obtaining UUID under Linux is shared

Source: Internet
Author: User
Tags printf uuid

Uuidgen can be used to generate on HP and Redhat, Solaris commands: Makeuuid

How do I get a UUID from C + + programming?

1. Install Libuuid Library, libuuid.so.1 in E2fsprogs, my system for RedHat7.3, download ftp://194.199.20.114/linux/redhat/7.3/en/os/i386/ redhat/rpms/e2fsprogs-1.27-3.i386.rpm

2. Edit File Uuid.cpp

Copy Code

The code is as follows:

#include ;

#include ;

#include ;

int main ()

{

uuid_t UU;

Uuid_generate (UU);

Std::cout << uu << Std::endl;

int i;

for (i=0;i<16;i++)

{

printf ("%x", UU);

}

printf ("n");

return 0;

}

#g + +-c–g uuid.o uuid.cpp

#g + +-o–luuid uuid UUID.O

The definition of uuid_t in/usr/include/uuid/uuid.h is:

typedef unsigned char uuid_t[16];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.