3

I'm using gflags to parse command line parameters of a c++ application (v140, x64). For some reason, I get different results on Release and Debug mode. In debug mode, the argument is not identified.

code

#include <gflags/gflags.h>
DEFINE_string(str_arg, "default param value", "string value");

int main(int argc, char *argv[])
{
    std::cout << "str value before glog init: " + FLAGS_str_arg << std::endl;
    //third parameter is set to false. setting it to true doesn't solve the problem
    google::ParseCommandLineFlags(&argc, &argv, false);
    std::cout << "str value after glog init: " + FLAGS_str_arg << std::endl;
}

execution command

app.exe -str_arg new_val

output in Release mode

str value before glog init: default param value
str value after glog init: new_val

output in Debug mode

str value before glog init: default param value
str value after glog init: default param value
ibezito
  • 5,782
  • 2
  • 22
  • 46
  • My crystal ball says that you forgot to set the arguments when you use the debugger. It is an extra step, Project > Properties > Debugging, "Command Arguments" setting. Also make sure that the Configuration and Platform comboboxes at the top of the dialog are set correctly, that goes wrong too often. – Hans Passant Apr 26 '18 at 09:29
  • @HansPassant Thanks, but I work through command line, so that's not the case – ibezito Apr 26 '18 at 09:30

1 Answers1

0

I had the same problem, that in debug mode strings are not showing up. To solve this problem i had to compile gflags release and debug libraries. In the install/bin directory there are now:

  • gflags.dll
  • gflags_debug.dll
MMatern
  • 1
  • 1