compiling rocksdb from sources on windows 10 (vstudio 2015)

hi All,
Its been ages since I programmed in C++. Forgot more than I remember. More as an exercise, I downloaded rocksdb sources and all the sources for dependent libraries. I managed to get all the dependent lib's built, and all but one of the rocskdb projects built.
One uses gflags is throwing a whole bunch of "error C2370: *** redefinition; different storage class..." errors. it is throwing a C2370 for every gflags definition. The declarations for all the flags are in the header file, look correct. I just remember that sometimes I got these if a function/variable was used without being declared, or before it was declared.
Any suggestions, maybe someone knows gflags or rocksdb, or more "how to fix" C2370? People report they are able to build, so I must be doing something wrong. I don't see any errors prior to the first C2370, but maybe a header file include is broken (one of those #ifdef or #ifndef)
THanks
MP
Last edited on
It's impossible to help from what you've posted without attempting to reproduce your work.
Thanks. I don't want you to do that. I'll get more specific info
In general, wonder if anyone built and is using gflags

https://github.com/gflags/gflags

in a windows visual studio 2015 C++ project. I'll get more info on the error from my other computer.
Last edited on
I don't have VS2015, but it builds ok on VS2019CE.
Thanks kbw. Just intalled 2019, still get the same error. Got some time to tinker with the project tonight.

Have a C++ project (visual studio 2019 now). It has a cpp file that has a bunch of gflags defines, like this:

DEFINE_uint64(seed, 2341234, "Seed for PRNG");

The header file has matching DECLARE macros.

DECLARE_uint64(seed);

When I run the build every single one of the DEFINE's get a storage class error:

Severity Code Description Project File Line Suppression State
Error C2370 'fLU64::FLAGS_seed': redefinition; different storage class db_stress C:\projects\rocksdb\db_stress_tool\db_stress_gflags.cc 22


If I rename the variable in the cpp file, in the DEFINE, to seed1, rebuild, then the error goes away for that variable, but in another cpp file, I get an undeclared variable error.

I think there must be a way to cause the compiler to expand the macros so I can see what the problem is. I think all the header files are in the right place, and the cmake build didn't modify any. Something wrong with the way the gflags macros are getting expanded on my system.

Last edited on
Ah /P preprocess to a file.
get the correct .vcxproj file, seem it's not now

redefinition is:
a function body lives or is included in more than one TU all of which must be ensured written in the .vcxproj
Last edited on
Im not quite "at one" with the compiler flags, I think. So if I expand the macros by hand, in the header file and in the cpp file, compilation fails the same way. So far so good (bad?)

Now the header expansion looks like this:
//DECLARE_uint64(seed);
namespace fLU64
{ extern ::google::uint64 FLAGS_seed;
} using fLU64::FLAGS_seed;

and the cpp expansion looks like this:

// DEFINE_uint64(seed, 2341234, "Seed for PRNG");
namespace fLU64 {
static const google::uint64 FLAGS_nonoseed = 2341234;
__declspec(dllexport) google::uint64 FLAGS_seed = FLAGS_nonoseed;
google::uint64 FLAGS_noseed = FLAGS_nonoseed;
static google::FlagRegisterer o_seed((const char*)"seed", (const char*)"Seed for PRNG", (const char*)"C:\\projects\\rocksdb\\dbstress_tool\\db_stress_gflags.cc", &FLAGS_seed, &FLAGS_noseed);
} // namespace fLU64
using fLU64::FLAGS_seed;


Now, if I take out __declspec(dllexport), so that the cpp file expansion looks lik ethis:

namespace fLU64 {
static const google::uint64 FLAGS_nonoseed = 2341234;
google::uint64 FLAGS_seed = FLAGS_nonoseed;
google::uint64 FLAGS_noseed = FLAGS_nonoseed;
static google::FlagRegisterer o_seed((const char*)"seed", (const char*)"Seed for PRNG", (const char*)"C:\\projects\\rocksdb\\dbstress_tool\\db_stress_gflags.cc", &FLAGS_seed, &FLAGS_noseed);
} // namespace fLU64
using fLU64::FLAGS_seed;

Then at least this line compiles, no errors.

So, I remember vaguely, ages ago, __declspec(dllexport).

Now, I tried to add __declspec(dllexport) to the header file part. Compiler didn't like that.

Googling . . .
(Hope maybe somebody new to C++ is going through something like this)






Thanks kbw. Just intalled 2019, still get the same error. Got some time to tinker with the project tonight.
Did you try to build your existing project or did you build a new one, a fresh checkout from github?
Just the old ones. Thanks for the tip, I'll get everything new and try again. Ive been doing all kind of tinkering to see what is wrong under the hood. Nice to move past this!! Thanks for the tip in vcxproj files.
Topic archived. No new replies allowed.