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];

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.