google::SetVersionString("0.3");
google::ParseCommandLineFlags(&argc, &argv, false);
I added a check to the boolean flag with "if (FLAG_myflag) { ... }" to check if the command-line args are successfully processed.
The project compiles without errors, I got some warnings regarding google::CommandLineFlagInfo::* but nothing fancy. However, when I call the binary with myprog.exe --longhelp --version --myflag --help it has no effect: The cout statement I added after the ParseCommandLineFlags statement does its output, but no help screen comes up and my flag is not set (it is initialized with false and it stays false despite of the "--myflag" parameter).
Can someone please tell me how I can dig into that any further?
Thank you!
Andreas
Hi equally named user,I tried to use static linking. In fact I initially wanted to achieve static linking but I wasn't able to get it working:I can switch the configuration type to static library (.lib) in the project options for libgflags. It compiles successfully with warnings but without errors. I get a libgflags.lib but my project using gflags doesn't build anymore: I get unsatisfied link errors for every gflags-call in my source file.In the file README_windows.txt is a description for static linking. It says I should add the parameters "/D GFLAGS_DLL_DECL= /D GFLAGS_DLL_DECLARE_FLAG= /D GFLAGS_DLL_DEFINE_FLAG=" for every gflags .cc file. I'm not exactly sure how to do this: I pasted it into the text area "additional options" under c/c++ / commandline in the project options and did a project rebuild after that. Maybe this is just wrong?
I switched to dll linking just because it was the only way for me to get around these unresolved link errors.
Hi Andreas,thank you very much. I’ve configured the branch without BUILD_SHARED_LIBS in cmake and compiled it with VS2013. I’ve created a super simple test project which defines a single boolean flag and outputs whether it has been set or not.
It builds just fine (linked statically against gflags) but the binary does not respond to -help, —help, /help, -longhelp, —lomghelp or /longhelp and not to my defined flag as well. It just ignores all parameters I gave it on the command line.