Building protobuf for Linux using VS2017

2019-08-05 02:40发布

问题:

I have configured VS2017 to build Linux C++ by remote building on a Linux Mint VM. I tried a simple C++ program and it compiles and executes fine, the thing is that now I need to add a generated protobuf source and the linking fails constantly.

On the Linux VM the protobuf generated files are building correctly and I was able to execute the gRPC examples.

The errors I get when I build from VS2017 are a lot of:

undefined reference to 'google::protobuf::internal'

and there is also this one

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Application Type\Linux\1.0\Linux.targets(262,5): error : Illegal characters in path.

I think this is a VS2017 remote compilation configuration issue, but I don't know what could it be.

Has it happened to you? Do you know how to solve this issue?

Thanks

SOLUTION: I the project properties go to Linker > All Options > Library dependencies and add: protobuf;pthread;grpc++;grpc

回答1:

This explains the "Illegal characters in path" message.

Does protobuf link to any libraries on the Linux system? Assuming you're not using CMake, have you added the libraries andtheir path(s) to the Visual Studio project - Library Dependencies and Additional Library Directories. This might help with specifying libraries.