Whim to see open source code, see the company's log library is in the Google-glog Open Source Library two times package, then first glog it.
1. Download the source code
One command fetch source: Git clone github.com/google/glog
2. compiling the library file
Double-click Open, right-click Compile, see Succeed, mood is good ~
3. Other engineering calls
A. Construction works
B. copy header file
C. Placing Lib Files
D. Placing DLL files
E. Testdemo engineering Configuration
Configuration one:
Configuration two:
Configuration three:
F. Running
G. A face of a crazy
H. conclusion
wash yourself and sleep!
compile using second hair
1. How does it hurt to be bitter?
2. Cause Analysis
Simple call all problems, uncomfortable, look at the source code.
My demo calls this macro to output
Then find this macro
A non-C + + base library file was called. Problem found.
The reason is that when the DLL library file is compiled, classes that are not base libraries are called. This class may be different on every different compiler, so compiling with VS2008 will cause problems with the VS2013 call, which is represented by a pointer error. and the static library must correspond to the compiler version number. The solution is also simple, VS2013 compile library file---->vs2013 call VS2008 Compile library file---->vs2008 call
3. Correcting errors
Use the VS2013 compiled library to solve the problem
4. What to learn
A. library file calls, resulting in abnormal memory read errors, etc... The issue is with the library file version. B. Common library files, dynamic libraries, must be compiled with C + + basic data types to be generic. C. Static libraries must be the same as the compiler version. D. Static library version errors can cause various link errors.
E. Natively compiled DLL files, when called can be directly connected to the source file, debugging test code is better:
1#include <iostream>2 3#include"glog/logging.h"4 5 intMain ()6 {7Google::initgooglelogging ("Log");8Google::setlogdestination (Google::glog_info,"./myinfo");9LOG (INFO) <<"hey ...";TenLOG (WARNING) <<"Oh ..."; OneLOG (ERROR) <<"hehe ..."; ALOG (FATAL) <<"haha ..."; -LOG (INFO) <<"hindering ..."; - the return 0; -}
5. Finally summed up the old feeling less write something, very grateful to colleagues WJ help, programming Road a person alone really difficult to go on, every time out of the wrong, always make people very confused. Some experience is not a search engine can search. The people who are willing to share are my role models.
Google-glog Compiling and using