Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLOG_<flag> vs. GOOGLE_<flag> #17

Open
GoogleCodeExporter opened this issue Jan 28, 2016 · 8 comments
Open

GLOG_<flag> vs. GOOGLE_<flag> #17

GoogleCodeExporter opened this issue Jan 28, 2016 · 8 comments

Comments

@GoogleCodeExporter
Copy link

Hi,

the documentation seems to be outdated.
It says:
"If the Google gflags library isn't installed, you set flags via
environment variables, prefixing the flag name with "GLOG_", e.g.

   GLOG_logtostderr=1 ./your_application
"

This does not work for me. I have to use the prefix "GOOGLE_" for making it
work. But I like "GLOG_" better since there might be other google libraries
involved.
Further but I can't say for sure yet: it seems that specifying via command
line flags does not work as specified in the documentation.

Regards

Original issue reported on code.google.com by jens.k.mueller@gmail.com on 15 Oct 2009 at 9:29

@GoogleCodeExporter
Copy link
Author

GLOG_ prefix should just work if you are not using gflags. Please make sure you 
don't 
have gflags installed and you are setting correct environment variable (note 
that 
GLOG should be capitalized, and logtostderr should not be capitalized). Some 
environment variables like GOOGLE_LOGTOSTDERR is defined by historical reason. 
I 
don't expect users of glog to use them.

Please post more details if you are still not able to use GLOG_ variables and 
I'll 
help to figure out why they aren't working as possible.

By the way, I guess I should make GLOG_* variables work even if gflags are 
installed...

Original comment by shinichi...@gmail.com on 23 Oct 2009 at 9:36

@GoogleCodeExporter
Copy link
Author

I think I had the problem that I installed gflags. Precisely, I told glog about
gflags. I guess that's why only GOOGLE_LOGTOSTDERR worked me. But I forgot to 
link
against the gflags library. That's why passing arguments didn't work. Having 
both
(environment and flags) to be working would be great.

Original comment by jens.k.mueller@gmail.com on 26 Oct 2009 at 9:56

@GoogleCodeExporter
Copy link
Author

Hi, I have a similar problem.. I have compiled glog version 0.3.0 and gflags was
installed at my machine (I have informed the CPPFLAGS and LDFLAGS to point to 
gflags
include and library dir respectively). The 'configure' script seems to find 
gflags,
but none of the --<flags> seems to work. GLOG_* flags didn't work either...

The application using glog must print the glog supported flags at --help 
command line
argument? Because it does not show any glog flags... My application is a test 
app
using google test, dont know if theres some issue using glog + gtest... 

Any hints? Thanks!

Original comment by pablo.c...@gmail.com on 7 Jan 2010 at 9:52

@GoogleCodeExporter
Copy link
Author

Yeah, you should see glog specific command line flags by --help like

  Flags from src/logging.cc:
    -alsologtoemail (log messages go to these email addresses in addition to
      logfiles) type: string default: ""
  ...

The glog specific flags should appear in the list of --help if you link glog 
(-lglog 
for your compiler if you're using linux). This should happen even if your 
source code 
doesn't use glog at all and you just need to link your program with glog. So, 
please 
make sure you are linking glog properly.

If this setting is fine, I have no idea so far... Please provide more 
information and 
I'll investigate as possible. Thanks.

Original comment by shinichi...@gmail.com on 12 Jan 2010 at 8:47

@GoogleCodeExporter
Copy link
Author

pablo, I think you forgot to initialize gflags in your program (jens probably 
did the
same). Easiest solution would be to just #include <gflags/gflags.h>, and insert
google::ParseCommandLineFlags(&argc, &argv, true); as the first line inside 
your main
function. Remember to link with -lgflags as well. I think this necessary step is
easily overlooked... perhaps there should be a small reminder in the glog
documentation page.

Original comment by jae.j...@gmail.com on 30 Jan 2010 at 3:45

@GoogleCodeExporter
Copy link
Author

Yeah. You're right. I recently did it as you say. I just would expect that glog 
is
doing this for me since it has this dependency. But I think since the 
dependency is
optional glog can't do so. Right? Having the documentation updated would be 
helpful.
So basically one has two options either using flags, then you have to
1. include <gflags/gflags.h>
2. call google::ParseCommandLineFlags
3. and link against gflags
or just set things via GLOG_* environment variables. For this you need no 
gflags at
all. But I can't get it to work. I attach a very simple program. I run it
$ GLOG_logtostderr=1 ./glog
But it keeps writing files to /tmp instead of logging to stderr.

Original comment by jens.k.mueller@gmail.com on 30 Jan 2010 at 1:32

Attachments:

@GoogleCodeExporter
Copy link
Author

I got an issue when compiling glog by running 'make' after running './configure'
Then I got an error: 

Undefined symbols for architecture x86_64:
  "testing::internal::StrStreamToString(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)", referenced from:
      testing::internal::String testing::internal::StreamableToString<void const*>(void const* const&) in logging_unittest-logging_unittest.o
      testing::internal::String testing::internal::StreamableToString<int>(int const&) in logging_unittest-logging_unittest.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [logging_unittest] Error 1

I am using glog-0.3.3 on Mac OS X. 
SO how can i turn of testing while compiling glog?

In another context, i installed glog and gflags by using Macport, then i run a 
small program. It will generate a error : 
"ERROR: unknown command line flag 'logtostderr'"

I believe that's the problem with linking to gflags. So how can i fix it. 
Thanks 

Original comment by phongngu...@gmail.com on 8 May 2014 at 6:17

@GoogleCodeExporter
Copy link
Author

As for the link error in logging_unittest, I think you have gtest installed and 
it is conflicting with glog for some reason. The easiest solution would be 
simply uninstalling gtest or ignore this error by make -k5000 or something and 
just use libglog.

As for the latter issue, I think you can use GLOG_logtostderr ./your_program or 
you can do GLOG_logtostderr=true at the beginning of your main(). 

Original comment by shinichi...@gmail.com on 8 May 2014 at 1:42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant