libuuid是一个开源的用于生成UUID(Universally Unique Identifier,通用唯一标识符)的库。

可从https://sourceforge.net/projects/libuuid/ 下载,最新版本为1.0.3,更新于2013年4月27日,此库仅支持在类Linux下编译使用。

之前在Windows上,我们产生guid(uuid在Windows上的叫法,是一个东西)可以使用API函数CoCreateGuid。

CrossGuid是一个最小的跨平台C ++ GUID库。它在给定平台上使用最好的本机GUID / UUID生成器,并具有用于解析,字符串化和比较ID的通用类。

可从https://github.com/graeme-hill/crossguid下载使用

接下来,我们在linux ubuntu上编译学习以下这两个库:

  • libuuid

  

  libuuid已经为我们提供了configure,直接./configure & make & make install三部曲即可,最终编译生成libuuid.a供程序链接使用,自带的一个C测试例子test_uuid.c,全部的终端执行如下:

Shell code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
 
michael@ubuntu:~/git$ cd ./libuuid-/
michael@ubuntu:~/git/libuuid-.3$ ls
aclocal.m4    config.h.in   depcomp      Makefile.in  test_uuid.c  uuidP.h
all-io.h      config.sub    gen_uuid.c   missing      unpack.c     uuid_time.c
c.h           configure     install-sh   pack.c       unparse.c
clear.c       configure.ac  isnull.c     parse.c      uuidd.h
compare.c     copy.c        ltmain.sh    randutils.c  uuid.h
config.guess  COPYING       Makefile.am  randutils.h  uuid.pc.in
michael@ubuntu:~/git/libuuid-.3$ ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum 
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for library containing socket... none required
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for inttypes.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking whether _SC_HOST_NAME_MAX is declared... yes
checking for int32_t... yes
checking for mode_t... yes
checking for size_t... yes
checking for ssize_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for uint8_t... yes
checking for ftruncate... yes
checking for gettimeofday... yes
checking for memset... yes
checking for socket... yes
checking for strtoul... yes
checking for usleep... yes
checking for srandom... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating uuid.pc
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
michael@ubuntu:~/git/libuuid-.3$ make
make  all-am
make[]: Entering directory '/home/michael/git/libuuid-1.0.3'
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-clear.lo -MD -MP -MF .deps/libuuid_la-clear.Tpo -c -o libuuid_la-clear.lo `test -f 'clear.c' || echo './'`clear.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-clear.lo -MD -MP -MF .deps/libuuid_la-clear.Tpo -c clear.c  -fPIC -DPIC -o .libs/libuuid_la-clear.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-clear.lo -MD -MP -MF .deps/libuuid_la-clear.Tpo -c clear.c -o libuuid_la-clear.o >/dev/null 
mv -f .deps/libuuid_la-clear.Tpo .deps/libuuid_la-clear.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-compare.lo -MD -MP -MF .deps/libuuid_la-compare.Tpo -c -o libuuid_la-compare.lo `test -f 'compare.c' || echo './'`compare.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-compare.lo -MD -MP -MF .deps/libuuid_la-compare.Tpo -c compare.c  -fPIC -DPIC -o .libs/libuuid_la-compare.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-compare.lo -MD -MP -MF .deps/libuuid_la-compare.Tpo -c compare.c -o libuuid_la-compare.o >/dev/null 
mv -f .deps/libuuid_la-compare.Tpo .deps/libuuid_la-compare.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-copy.lo -MD -MP -MF .deps/libuuid_la-copy.Tpo -c -o libuuid_la-copy.lo `test -f 'copy.c' || echo './'`copy.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-copy.lo -MD -MP -MF .deps/libuuid_la-copy.Tpo -c copy.c  -fPIC -DPIC -o .libs/libuuid_la-copy.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-copy.lo -MD -MP -MF .deps/libuuid_la-copy.Tpo -c copy.c -o libuuid_la-copy.o >/dev/null 
mv -f .deps/libuuid_la-copy.Tpo .deps/libuuid_la-copy.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-gen_uuid.lo -MD -MP -MF .deps/libuuid_la-gen_uuid.Tpo -c -o libuuid_la-gen_uuid.lo `test -f 'gen_uuid.c' || echo './'`gen_uuid.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-gen_uuid.lo -MD -MP -MF .deps/libuuid_la-gen_uuid.Tpo -c gen_uuid.c  -fPIC -DPIC -o .libs/libuuid_la-gen_uuid.o
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:,
                 from /usr/include/stdio.h:,
                 from gen_uuid.c::
/usr/include/features.h:: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^~~~~~~
gen_uuid.c: In function 'get_clock':
gen_uuid.c:: warning: implicit declaration of function 'flock'; did you mean 'clock'? [-Wimplicit-function-declaration]
   ) {
          ^~~~~
          clock
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-gen_uuid.lo -MD -MP -MF .deps/libuuid_la-gen_uuid.Tpo -c gen_uuid.c -o libuuid_la-gen_uuid.o >/dev/null 
mv -f .deps/libuuid_la-gen_uuid.Tpo .deps/libuuid_la-gen_uuid.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-isnull.lo -MD -MP -MF .deps/libuuid_la-isnull.Tpo -c -o libuuid_la-isnull.lo `test -f 'isnull.c' || echo './'`isnull.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-isnull.lo -MD -MP -MF .deps/libuuid_la-isnull.Tpo -c isnull.c  -fPIC -DPIC -o .libs/libuuid_la-isnull.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-isnull.lo -MD -MP -MF .deps/libuuid_la-isnull.Tpo -c isnull.c -o libuuid_la-isnull.o >/dev/null 
mv -f .deps/libuuid_la-isnull.Tpo .deps/libuuid_la-isnull.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-pack.lo -MD -MP -MF .deps/libuuid_la-pack.Tpo -c -o libuuid_la-pack.lo `test -f 'pack.c' || echo './'`pack.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-pack.lo -MD -MP -MF .deps/libuuid_la-pack.Tpo -c pack.c  -fPIC -DPIC -o .libs/libuuid_la-pack.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-
mv -f .deps/libuuid_la-pack.Tpo .deps/libuuid_la-pack.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-parse.lo -MD -MP -MF .deps/libuuid_la-parse.Tpo -c -o libuuid_la-parse.lo `test -f 'parse.c' || echo './'`parse.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-parse.lo -MD -MP -MF .deps/libuuid_la-parse.Tpo -c parse.c  -fPIC -DPIC -o .libs/libuuid_la-parse.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-parse.lo -MD -MP -MF .deps/libuuid_la-parse.Tpo -c parse.c -o libuuid_la-parse.o >/dev/null 
mv -f .deps/libuuid_la-parse.Tpo .deps/libuuid_la-parse.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-unpack.lo -MD -MP -MF .deps/libuuid_la-unpack.Tpo -c -o libuuid_la-unpack.lo `test -f 'unpack.c' || echo './'`unpack.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-unpack.lo -MD -MP -MF .deps/libuuid_la-unpack.Tpo -c unpack.c  -fPIC -DPIC -o .libs/libuuid_la-unpack.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-
mv -f .deps/libuuid_la-unpack.Tpo .deps/libuuid_la-unpack.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-unparse.lo -MD -MP -MF .deps/libuuid_la-unparse.Tpo -c -o libuuid_la-unparse.lo `test -f 'unparse.c' || echo './'`unparse.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-unparse.lo -MD -MP -MF .deps/libuuid_la-unparse.Tpo -c unparse.c  -fPIC -DPIC -o .libs/libuuid_la-unparse.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-unparse.lo -MD -MP -MF .deps/libuuid_la-unparse.Tpo -c unparse.c -o libuuid_la-unparse.o >/dev/null 
mv -f .deps/libuuid_la-unparse.Tpo .deps/libuuid_la-unparse.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-uuid_time.lo -MD -MP -MF .deps/libuuid_la-uuid_time.Tpo -c -o libuuid_la-uuid_time.lo `test -f 'uuid_time.c' || echo './'`uuid_time.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-uuid_time.lo -MD -MP -MF .deps/libuuid_la-uuid_time.Tpo -c uuid_time.c  -fPIC -DPIC -o .libs/libuuid_la-uuid_time.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-uuid_time.lo -MD -MP -MF .deps/libuuid_la-uuid_time.Tpo -c uuid_time.c -o libuuid_la-uuid_time.o >/dev/null 
mv -f .deps/libuuid_la-uuid_time.Tpo .deps/libuuid_la-uuid_time.Plo
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I. -g -O2 -MT libuuid_la-randutils.lo -MD -MP -MF .deps/libuuid_la-randutils.Tpo -c -o libuuid_la-randutils.lo `test -f 'randutils.c' || echo './'`randutils.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-randutils.lo -MD -MP -MF .deps/libuuid_la-randutils.Tpo -c randutils.c  -fPIC -DPIC -o .libs/libuuid_la-randutils.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I. -g -O2 -MT libuuid_la-randutils.lo -MD -MP -MF .deps/libuuid_la-randutils.Tpo -c randutils.c -o libuuid_la-randutils.o >/dev/null 
mv -f .deps/libuuid_la-randutils.Tpo .deps/libuuid_la-randutils.Plo
/bin/bash ./libtool  --tag=CC   --mode=  -o libuuid.la -rpath /usr/local/lib libuuid_la-clear.lo libuuid_la-compare.lo libuuid_la-copy.lo libuuid_la-gen_uuid.lo libuuid_la-isnull.lo libuuid_la-pack.lo libuuid_la-parse.lo libuuid_la-unpack.lo libuuid_la-unparse.lo libuuid_la-uuid_time.lo libuuid_la-randutils.lo   
libtool: 
libtool: link: (cd ".libs" && rm -f "libuuid.so.1" && ln -s "libuuid.so.1.0.0" "libuuid.so.1")
libtool: link: (cd ".libs" && rm -f "libuuid.so" && ln -s "libuuid.so.1.0.0" "libuuid.so")
libtool: link: ar cru .libs/libuuid.a  libuuid_la-clear.o libuuid_la-compare.o libuuid_la-copy.o libuuid_la-gen_uuid.o libuuid_la-isnull.o libuuid_la-pack.o libuuid_la-parse.o libuuid_la-unpack.o libuuid_la-unparse.o libuuid_la-uuid_time.o libuuid_la-randutils.o
ar: `u' modifier ignored since `D' is the default (see `U')
libtool: link: ranlib .libs/libuuid.a
libtool: link: ( cd ".libs" && rm -f "libuuid.la" && ln -s "../libuuid.la" "libuuid.la" )
make[]: Leaving directory '/home/michael/git/libuuid-1.0.3'
michael@ubuntu:~/git/libuuid-.3$ make install
make[]: Entering directory '/home/michael/git/libuuid-1.0.3'
 /bin/mkdir -p '/usr/local/lib'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   libuuid.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libuuid.so.
/usr/bin/install: cannot create regular file '/usr/local/lib/libuuid.so.1.0.0': Permission denied
make[
make[]: Leaving directory '/home/michael/git/libuuid-1.0.3'
make: *** [Makefile:
michael@ubuntu:~/git/libuuid-.3$ sudo make install
[sudo] password for michael: 
make[]: Entering directory '/home/michael/git/libuuid-1.0.3'
 /bin/mkdir -p '/usr/local/lib'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   libuuid.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libuuid.so.
libtool: install: (cd /usr/; }; })
libtool: install: (cd /usr/ libuuid.so; }; })
libtool: install: /usr/bin/install -c .libs/libuuid.lai /usr/local/lib/libuuid.la
libtool: install: /usr/bin/install -c .libs/libuuid.a /usr/local/lib/libuuid.a
libtool: install:  /usr/local/lib/libuuid.a
libtool: install: ranlib /usr/local/lib/libuuid.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld() manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c - uuid.pc '/usr/local/lib/pkgconfig'
 /bin/mkdir -p '/usr/local/include/uuid'
 /usr/bin/install -c - uuid.h '/usr/local/include/uuid'
make[]: Leaving directory '/home/michael/git/libuuid-1.0.3'
michael@ubuntu:~/git/libuuid-.3$ ls
aclocal.m4     gen_uuid.c              libuuid_la-pack.o        pack.c
all-io.h       install-sh              libuuid_la-parse.lo      parse.c
c.h            isnull.c                libuuid_la-parse.o       randutils.c
clear.c        libtool                 libuuid_la-randutils.lo  randutils.h
compare.c      libuuid.la              libuuid_la-randutils.o   stamp-h1
config.guess   libuuid_la-clear.lo     libuuid_la-unpack.lo     test_uuid.c
config.h       libuuid_la-clear.o      libuuid_la-unpack.o      unpack.c
config.h.in    libuuid_la-compare.lo   libuuid_la-unparse.lo    unparse.c
config.log     libuuid_la-compare.o    libuuid_la-unparse.o     uuidd.h
config.status  libuuid_la-copy.lo      libuuid_la-uuid_time.lo  uuid.h
config.sub     libuuid_la-copy.o       libuuid_la-uuid_time.o   uuid.pc
configure      libuuid_la-gen_uuid.lo  ltmain.sh                uuid.pc.in
configure.ac   libuuid_la-gen_uuid.o   Makefile                 uuidP.h
copy.c         libuuid_la-isnull.lo    Makefile.am              uuid_time.c
COPYING        libuuid_la-isnull.o     Makefile.in
depcomp        libuuid_la-pack.lo      missing
michael@ubuntu:~/git/libuuid-.3$ vim ./test_uuid.c 
michael@ubuntu:~/git/libuuid-.3$ gcc test_uuid.c -o test_uuid
/usr/bin/ld: /tmp/ccRUh9Vk.o: in function `test_uuid':
test_uuid.c:(.text+0x2d): undefined reference to `uuid_parse'
/usr/bin/ld: /tmp/ccRUh9Vk.o: in function `main':
test_uuid.c:(.text+0x10a): undefined reference to `uuid_generate'
/usr/bin/ld: test_uuid.c:(.text+0x120): undefined reference to `uuid_unparse'
/usr/bin/ld: test_uuid.c:(.text+0x1b7): undefined reference to `uuid_type'
/usr/bin/ld: test_uuid.c:(.text+0x1cc): undefined reference to `uuid_variant'
/usr/bin/ld: test_uuid.c:(.text+0x226): undefined reference to `uuid_generate_random'
/usr/bin/ld: test_uuid.c:(.text+0x23c): undefined reference to `uuid_unparse'
/usr/bin/ld: test_uuid.c:(.text+0x2d3): undefined reference to `uuid_type'
/usr/bin/ld: test_uuid.c:(.text+0x2e8): undefined reference to `uuid_variant'
/usr/bin/ld: test_uuid.c:(.text+0x35e): undefined reference to `uuid_generate_time'
/usr/bin/ld: test_uuid.c:(.text+0x374): undefined reference to `uuid_unparse'
/usr/bin/ld: test_uuid.c:(.text+0x40b): undefined reference to `uuid_type'
/usr/bin/ld: test_uuid.c:(.text+0x420): undefined reference to `uuid_variant'
/usr/bin/ld: test_uuid.c:(.text+0x4b1): undefined reference to `uuid_time'
/usr/bin/ld: test_uuid.c:(.text+0x4ff): undefined reference to `uuid_parse'
/usr/bin/ld: test_uuid.c:(.text+0x515): undefined reference to `uuid_compare'
/usr/bin/ld: test_uuid.c:(.text+0x546): undefined reference to `uuid_clear'
/usr/bin/ld: test_uuid.c:(.text+0x552): undefined reference to `uuid_is_null'
/usr/bin/ld: test_uuid.c:(.text+0x58d): undefined reference to `uuid_copy'
/usr/bin/ld: test_uuid.c:(.text+0x5a3): undefined reference to `uuid_compare'
 exit status
michael@ubuntu:~/git/libuuid-.3$ cd /usr/local/lib
michael@ubuntu:/usr/local/lib$ ls
lib3ds-
lib3ds-  lib3ds.so  libuuid.so    pkgconfig
lib3ds.a           libuuid.a  libuuid.so.
michael@ubuntu:/usr//
michael@ubuntu:~/git/libuuid-.3$ gcc test_uuid.c -luuid -o test_uuid
michael@ubuntu:~/git/libuuid-.3$ ls
aclocal.m4     gen_uuid.c              libuuid_la-pack.o        pack.c
all-io.h       install-sh              libuuid_la-parse.lo      parse.c
c.h            isnull.c                libuuid_la-parse.o       randutils.c
clear.c        libtool                 libuuid_la-randutils.lo  randutils.h
compare.c      libuuid.la              libuuid_la-randutils.o   stamp-h1
config.guess   libuuid_la-clear.lo     libuuid_la-unpack.lo     test_uuid
config.h       libuuid_la-clear.o      libuuid_la-unpack.o      test_uuid.c
config.h.in    libuuid_la-compare.lo   libuuid_la-unparse.lo    unpack.c
config.log     libuuid_la-compare.o    libuuid_la-unparse.o     unparse.c
config.status  libuuid_la-copy.lo      libuuid_la-uuid_time.lo  uuidd.h
config.sub     libuuid_la-copy.o       libuuid_la-uuid_time.o   uuid.h
configure      libuuid_la-gen_uuid.lo  ltmain.sh                uuid.pc
configure.ac   libuuid_la-gen_uuid.o   Makefile                 uuid.pc.in
copy.c         libuuid_la-isnull.lo    Makefile.am              uuidP.h
COPYING        libuuid_la-isnull.o     Makefile.in              uuid_time.c
depcomp        libuuid_la-pack.lo      missing
michael@ubuntu:~/git/libuuid-.3$ ./test_uuid 
UUID generate = 53ead8bd-e562-4e79-bf6a-4e7cbf4c331d
UUID: 53ead8bde5624e79bf6a4e7cbf4c331d
UUID type =

UUID random string = dacba404--47c3-b8de-f451f843b849
UUID: dacba404235047c3b8def451f843b849
UUID type =

UUID string = 6c7dffbe-d07d-11e9-9d41-000c2977e04e
UUID time: 6c7dffbed07d11e99d41000c2977e04e
UUID type = 
UUID

UUID parse and compare succeeded.
UUID clear and is null succeeded.
UUID copy and compare succeeded.
84949cc5--4a84-895b-354c584a981b is valid, OK
84949CC5--4A84-895B-354C584A981B is valid, OK
84949cc5--4a84-895b-354c584a981bc is invalid, OK
84949cc5--4a84-895b-354c584a981 is invalid, OK
84949cc5x4701-4a84-895b-354c584a981b is invalid, OK
84949cc504701-4a84-895b-354c584a981b is invalid, OK
84949cc5-470104a84-895b-354c584a981b is invalid, OK
84949cc5--4a840895b-354c584a981b is invalid, OK
84949cc5--4a84-895b0354c584a981b is invalid, OK
g4949cc5--4a84-895b-354c584a981b is invalid, OK
84949cc5--4a84-895b-354c584a981g is invalid, OK
michael@ubuntu:~/git/libuuid-.3$ 

  

  • crossguid

  

  crossguid则为我们提供了CMakeLists.txt,方便我们使用cmake的方式来构建,构建成功后会生成一个libcrossguid.a 静态库和测试程序 crossguid-test ,全部的终端执行如下:

 Shell Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
michael@ubuntu:~$ cd ./git/crossguid-master/
michael@ubuntu:~/git/crossguid-master$ ls
android     cmake           crossguid.pc.in  LICENSE    src
android.sh  CMakeLists.txt  include          README.md  test
michael@ubuntu:~/git/crossguid-master$ mkdir build
michael@ubuntu:~/git/crossguid-master$ cd ./build/
michael@ubuntu:~/git/crossguid-master/build$ cmake --version
cmake version

CMake suite maintained and supported by Kitware (kitware.com/cmake).
michael@ubuntu:~/git/crossguid-master/build$ cmake ..
-- The C compiler identification 
-- The CXX compiler identification 
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Found LibUUID: /usr/lib/x86_64-linux-gnu/libuuid.so (found version "2.32.0") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/michael/git/crossguid-master/build
michael@ubuntu:~/git/crossguid-master/build$ make
Scanning dependencies of target crossguid
[ %] Building CXX object CMakeFiles/crossguid.dir/src/guid.cpp.o
[ %] Linking CXX static library libcrossguid.a
[ %] Built target crossguid
Scanning dependencies of target crossguid-test
[ %] Building CXX object CMakeFiles/crossguid-test.dir/test/TestMain.cpp.o
[ %] Building CXX object CMakeFiles/crossguid-test.dir/test/Test.cpp.o
[%] Linking CXX executable crossguid-test
[%] Built target crossguid-test
michael@ubuntu:~/git/crossguid-master/build$ make install
[ %] Built target crossguid
[%] Built target crossguid-test
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libcrossguid.a
CMake Error at cmake_install.cmake: (file):
  file INSTALL cannot copy file
  "/home/michael/git/crossguid-master/build/libcrossguid.a" to
  "/usr/local/lib/libcrossguid.a".

make: *** [Makefile:
michael@ubuntu:~/git/crossguid-master/build$ ls
CMakeCache.txt  cmake_install.cmake  crossguid-test  Makefile
CMakeFiles      crossguid.pc         libcrossguid.a
michael@ubuntu:~/git/crossguid-master/build$ ./crossguid-test 
66ea935c-730c--82b3-f12424544a5b
73cecead-39c4--8a7e-029df3629f28
82aea220-ad0b-41d7-8c83-668a31fdcb47
All tests passed!
michael@ubuntu:~/git/crossguid-master/build$ 

  具体函数使用请参考官方文档,本文到此为止。

UUID生成库libuuid和crossguid的更多相关文章

  1. UUID 生成(源代码编译)

    根据定义,UUID(Universally Unique IDentifier,也称GUID)在时间和空间都是唯一的.为保证空间的唯一性,每个UUID使用了一个48位的值来记录,一般是计算机的网卡地址 ...

  2. 一个UUID生成算法的C语言实现 --- WIN32版本 .

    一个UUID生成算法的C语言实现——WIN32版本   cheungmine 2007-9-16   根据定义,UUID(Universally Unique IDentifier,也称GUID)在时 ...

  3. js页码生成库,一个适合前后端分离的页码生成器

    原文:js页码生成库,一个适合前后端分离的页码生成器 前言 上星期写的任务里面有需要进行分页的处理,git搜索了一番,没有觉得合适的,于是自己临时写了个分页的算法. 然后等闲下来的时候,决定把分页进行 ...

  4. [C#] BarcodeLib -- 一个精简而不失优雅的条形码生成库

    BarcodeLib -- 一个精简而不失优雅的条形码生成库 引言 在百度进行“C# 条形码”等类似关键字搜索的时候,基本上是使用 ZXing 类库进行条形码的生成.今天我所介绍的是另一款类库 Bar ...

  5. java自带uuid生成

    java自带uuid生成UUID.randomUUID().toString()

  6. 二维码js生成库

    jr-qrcode 把字符串生成二维码,并以Base64 URL形式输出. 支持白色二维码,即反色二维码. 兼容性 插件使用了H5的canvas特性进行二维码绘制,最后输出base64 url,因此本 ...

  7. 一个UUID生成算法的C语言实现——WIN32版本

    源: 一个UUID生成算法的C语言实现——WIN32版本

  8. BarcodeLib -- 一个精简而不失优雅的条形码生成库

    BarcodeLib -- 一个精简而不失优雅的条形码生成库 引言 在百度进行“C# 条形码”等类似关键字搜索的时候,基本上是使用 ZXing 类库进行条形码的生成.今天我所介绍的是另一款类库 Bar ...

  9. UUID 生成32位随机串

    java通过jdk自带的UUID,生成32位的随机串 private static String generate_UUID() { UUID uuid=UUID.randomUUID(); Stri ...

随机推荐

  1. 多线程(四)多线程同步_Critical Section临界区

    临界区是指一个小代码段,在代码能够执行前,它必须独占对某些共享资源的访问权.和使用mutex一样,它们都是以原子操作方式来对共享资源进行访问. 临界区又叫关键代码段,与上一篇的mutex互斥体实现的功 ...

  2. 生鲜超市项目错误及解决办法(安装mysqlclient)

    错误1:安装Mysqlclient D:\Mxshop>pip install mysqlclient- 1.4.4-cp27-cp27m-win32 报错: ERROR: Could not ...

  3. webapi基于单请求封装多请求的设计【转】

    怎么说,单请求封装多请求,这句话确实有点绕了,但还是要看清楚,想明白这到底是怎么一回事,单请求即一次请求(get,post,put,delete),封闭多请求,即在客户端发送的一个请求中可能包含多个子 ...

  4. 原生js-input框全选

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 【HDU6327】Random Sequence(记忆化搜索)

    点此看题面 大致题意: 给你两个序列\(a,v\),其中\(a\)数组由\(0\sim m\)组成.随机用\(1\sim m\)中的一个数替换\(a\)中的\(0\),求\(\sum_{i=1}^{n ...

  6. stm32环境搭建

    软件下载:https://pan.baidu.com/s/1rat9Vnm 第一部分:软件安装 1.点击安装mdk514.exe,一路next就可以了 2.使用管理员身份打开软件,点击File,进到l ...

  7. Web协议详解与抓包实战:HTTP1协议-详解请求行(2)

    一.请求行一 二.请求行二 三.请求行三 四.常见方法(RFC7231) 实际测试截图 五.用于文档管理的 WEBDAV 方法(RFC2518) 六.WEBDAV 验证环境  1.登录  2.Wire ...

  8. Spring security 知识笔记【入门】

    一.生成spring boot项目文件 二.pom文件如下 <?xml version="1.0" encoding="UTF-8"?> <p ...

  9. 推荐一款移动端日历App吉日历

    推荐一款移动端日历App吉日历 一 应用描述 万年历.日历.农历.黄历.假期安排.天气预报.记事提醒便捷查看,一目了然! 二 功能介绍: 1.万年历:精美的日期展示,完整的节日日历随意查看,节假日.休 ...

  10. docker下oracle的awr报告下载