shanewfx / google-glog

Automatically exported from code.google.com/p/google-glog
Other
0 stars 0 forks source link

link error when using glog with gflags on windows(error LNK2005) #61

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. static link gflags (see a patch for this: 
http://code.google.com/p/google-gflags/issues/detail?id=37)
2. build 'logging_unittest_static' project in solution provided
3. link error is reported:
libglog_static.lib(port.obj) : error LNK2005: "int __cdecl snprintf(char 
*,unsigned int,char const *,...)" (?snprintf@@YAHPADIPBDZZ) already defined in 
libgflags_static-debug.lib(port.obj) 

What version of the product are you using? On what operating system?
glog/gflags, both last version from svn.
vs2008 sp1

Please provide any additional information below.
The error is caused by multiple definition of ''snprintf". Both glog and gflags 
provide one in respective 'port.cc'. Maybe need a macro to prevent this 
situation.

Note that if we explicitly specify link order that 'link glog BEFORE gflags', 
the error will be gone. On the contrary, 'logging_unittest_static' project is 
set to 'Depend on libglog_static project', which implicitly makes glog linked 
AFTER gflags, which cause the error. However, using this link order hack seems 
not the right way to solve this.

Original issue reported on code.google.com by frank28 on 18 Aug 2010 at 2:21