Compile Protocol Buffers 2.6.1 using VS 2015?

2019-04-28 23:03发布

I want to use ProtoBuf 2.6.1 with a VS 2015 C++ application. However, I can't link against libprotobuf.lib compiled using VS 2013. I tried to compile libprotobuf.lib again using VS 2015, but am running into compile errors, complaining about <hash_map> and <hash_set> being deprecated.

It looks like the cmake files for ProtoBuf at the GitHub repo are now all set up for ProtoBuf 3.0. Is it still possible to compile libprotobuf using VS 2015?

3条回答
劫难
2楼-- · 2019-04-28 23:19

Unfortunately, cmake build is available starting from protobuf v3.0.0-alpha.

I've successfully built protobuf v2.6.1 with MSVC 2015 using following unofficial cmake scripts. You need branch updated_for_v2.6.1 from that repository.

For that clone both repositories - protobuf and protobuf-cmake.

Checkout tag v2.6.1 in protobuf clone and branch origin/updated_for_v2.6.1 in protobuf-cmake

cmake < here path to protobuf-cmake clone > -DPROTOBUF_ROOT=< here path to protobuf clone > -G"Visual Studio 14 2015" -DCMAKE_INSTALL_PREFIX= < here path for install target >

Then build it as usual either from opened solution or using "cmake --build ." command

HTH.

查看更多
ゆ 、 Hurt°
3楼-- · 2019-04-28 23:23

To get the unit tests running you also need to modify a couple of tests that concatenate strings with a preprocessor macro in the middle. Just add a space either side of the macro and the compiler parser can cope again.

A couple of tests fail on running due to directory forward vs back slash when creating temp filenames but those don't matter.

Otherwise no problems. PS I can't actually check but that may have been my experiences with v3 alpha rather than 261 as I'm doing this from memory.

Both build OK on the RC and I think our Jenkins jobs have rebuilt them since moving to 2015 prof RTM

查看更多
萌系小妹纸
4楼-- · 2019-04-28 23:28

You can refer build error with Visual Studio 2015 #314.

Thank you for the report but we don't support Visual Studio 2015 right now. Please use Visual Studio 2013 instead until we officially switch to Visual Studio 2015.

Note that we do have a plan to switch to Visual Studio 2015, but I'd like to focus on other high priority issues at the moment. Please subscribe #315 if you are interested in the progress on Visual Studio 2015 support in Mozc for Windows.

That said, just fixing build failures is not so difficult. I've uploaded a proof-of-concept change 518f41a into support_msvs_2015 branch just for your reference.

查看更多
登录 后发表回答