使用带线程版本:
g++ gflagsTest.cpp -lgflags -lpthread -o test
使用不带线程版本:
g++ gflagsTest.cpp -lgflags_nothreads -o test
运行
root@ubuntu:~/workspace$ ./test -dst=a.bmp
a.bmp
root@ubuntu:~/workspace$ ./test --dst=a.bmp
a.bmp
root@ubuntu:~/workspace$ ./test --dst a.bmp
a.bmp
root@ubuntu:~/workspace$ ./test -dst a.bmp
a.bmp
root@ubuntu:~/workspace$ ./test
xxxx.bmp
root@ubuntu:~/workspace$ ./test -dst
ERROR: flag '-dst' is missing its argument; flag description: dst bmp file
root@ubuntu:~/workspace$ ./test -help
test: Warning: SetUsageMessage() never called
Flags from /home/lwh/workspace/gflags-2.2.2/src/gflags.cc:
-flagfile (load flags from file) type: string default: ""
-fromenv (set flags from the environment [use 'export FLAGS_flag1=value'])
type: string default: ""
-tryfromenv (set flags from the environment if present) type: string
default: ""
-undefok (comma-separated list of flag names that it is okay to specify on
the command line even if the program does not define a flag with that
name. IMPORTANT: flags in this list that have arguments MUST use the
flag=value format) type: string default: ""
Flags from /home/lwh/workspace/gflags-2.2.2/src/gflags_completions.cc:
-tab_completion_columns (Number of columns to use in output for tab
completion) type: int32 default: 80
-tab_completion_word (If non-empty, HandleCommandLineCompletions() will
hijack the process and attempt to do bash-style command line flag
completion on this value.) type: string default: ""
Flags from /home/lwh/workspace/gflags-2.2.2/src/gflags_reporting.cc:
-help (show help on all flags [tip: all flags can have two dashes])
type: bool default: false currently: true
-helpfull (show help on all flags -- same as -help) type: bool
default: false
-helpmatch (show help on modules whose name contains the specified substr)
type: string default: ""
-helpon (show help on the modules named by this flag value) type: string
default: ""
-helppackage (show help on all modules in the main package) type: bool
default: false
-helpshort (show help on only the main module for this program) type: bool
default: false
-helpxml (produce an xml version of help) type: bool default: false
-version (show version and build info and exit) type: bool default: false
Flags from gflagsTest.cpp:
-dst (dst bmp file) type: string default: "xxxx.bmp"