在网站 http://code.google.com/p/protobuf/downloads/list上可以下载 Protobuf 的源代码。然后解压编译安装便可以使用它了。
使用2.4.1版本,
源代码目录下vsprojects/libprotobuf-lite.vcproj,以及自己整理的lite工程,
(1):Create a Win32 Smart Device Project library project, name it protobuf-lite-ce
(2):Copy all source files from protobuf-lite project to protobuf-lite-ce project in Solution Explorer
(3):Create a ce_port folder in the project's directory, and copy the errno.h header file from (Visual_Studio_Root)/VC/include into the folder. This is because Windows CE doesn't have this file, so we need to provide one. Actually, this errno.h can be a pure empty file.
(4):Add "../src;.;./ce_port" to the project's Additional Include Directories.
(5):The windef.h header file already defines OPTIONAL macro, it conflicts with Cardinality::OPTIONAL enum. So theextension_set.cc fails to compile, to solve this, add following code before enum Cardinality definition to undefine OPTIONAL:
#if defined(OPTIONAL)
#if defined(_MSC_VER)
#pragma message ("Unexpected OPTIONAL macro definition, #undefine OPTIONAL")
#else
#warning "Unexpected OPTIONAL macro definition, #undefine OPTIONAL"
#endif
#undef OPTIONAL
#endif
namespace {
enum Cardinality {
REPEATED,
OPTIONAL
};
} // namespace