Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
5.9 KiB

  1. This directory contains project files for compiling Protocol Buffers using
  2. MSVC. This is not the recommended way to do Protocol Buffer development --
  3. we prefer to develop under a Unix-like environment -- but it may be more
  4. accessible to those who primarily work with MSVC.
  5. Compiling and Installing
  6. ========================
  7. 1) Open protobuf.sln in Microsoft Visual Studio.
  8. 2) Choose "Debug" or "Release" configuration as desired.*
  9. 3) From the Build menu, choose "Build Solution". Wait for compiling to finish.
  10. 4) From a command shell, run tests.exe and lite-test.exe and check that all
  11. tests pass.
  12. 5) Run extract_includes.bat to copy all the public headers into a separate
  13. "include" directory (under the top-level package directory).
  14. 6) Copy the contents of the include directory to wherever you want to put
  15. headers.
  16. 7) Copy protoc.exe wherever you put build tools (probably somewhere in your
  17. PATH).
  18. 8) Copy libprotobuf.lib, libprotobuf-lite.lib, and libprotoc.lib wherever you
  19. put libraries.
  20. * To avoid conflicts between the MSVC debug and release runtime libraries, when
  21. compiling a debug build of your application, you may need to link against a
  22. debug build of libprotobuf.lib. Similarly, release builds should link against
  23. release libs.
  24. DLLs vs. static linking
  25. =======================
  26. Static linking is now the default for the Protocol Buffer libraries. Due to
  27. issues with Win32's use of a separate heap for each DLL, as well as binary
  28. compatibility issues between different versions of MSVC's STL library, it is
  29. recommended that you use static linkage only. However, it is possible to
  30. build libprotobuf and libprotoc as DLLs if you really want. To do this,
  31. do the following:
  32. 1) Open protobuf.sln in MSVC.
  33. 2) For each of the projects libprotobuf, libprotobuf-lite, and libprotoc, do
  34. the following:
  35. 2a) Right-click the project and choose "properties".
  36. 2b) From the side bar, choose "General", under "Configuration Properties".
  37. 2c) Change the "Configuration Type" to "Dynamic Library (.dll)".
  38. 2d) From the side bar, choose "Preprocessor", under "C/C++".
  39. 2e) Add PROTOBUF_USE_DLLS to the list of preprocessor defines.
  40. 3) When compiling your project, make sure to #define PROTOBUF_USE_DLLS.
  41. When distributing your software to end users, we strongly recommend that you
  42. do NOT install libprotobuf.dll or libprotoc.dll to any shared location.
  43. Instead, keep these libraries next to your binaries, in your application's
  44. own install directory. C++ makes it very difficult to maintain binary
  45. compatibility between releases, so it is likely that future versions of these
  46. libraries will *not* be usable as drop-in replacements.
  47. If your project is itself a DLL intended for use by third-party software, we
  48. recommend that you do NOT expose protocol buffer objects in your library's
  49. public interface, and that you statically link protocol buffers into your
  50. library.
  51. ZLib support
  52. ============
  53. If you want to include GzipInputStream and GzipOutputStream
  54. (google/protobuf/io/gzip_stream.h) in libprotoc, you will need to do a few
  55. additional steps:
  56. 1) Obtain a copy of the zlib library. The pre-compiled DLL at zlib.net works.
  57. 2) Make sure zlib's two headers are in your include path and that the .lib file
  58. is in your library path. You could place all three files directly into the
  59. vsproject directory to compile libprotobuf, but they need to be visible to
  60. your own project as well, so you should probably just put them into the
  61. VC shared icnlude and library directories.
  62. 3) Right-click on the "tests" project and choose "properties". Navigate the
  63. sidebar to "Configuration Properties" -> "Linker" -> "Input".
  64. 4) Under "Additional Dependencies", add the name of the zlib .lib file (e.g.
  65. zdll.lib). Make sure to update both the Debug and Release configurations.
  66. 5) If you are compiling libprotobuf and libprotoc as DLLs (see previous
  67. section), repeat steps 2 and 3 for the libprotobuf and libprotoc projects.
  68. If you are compiling them as static libraries, then you will need to link
  69. against the zlib library directly from your own app.
  70. 6) Edit config.h (in the vsprojects directory) and un-comment the line that
  71. #defines HAVE_ZLIB. (Or, alternatively, define this macro via the project
  72. settings.)
  73. Notes on Compiler Warnings
  74. ==========================
  75. The following warnings have been disabled while building the protobuf libraries
  76. and compiler. You may have to disable some of them in your own project as
  77. well, or live with them.
  78. C4018 - 'expression' : signed/unsigned mismatch
  79. C4146 - unary minus operator applied to unsigned type, result still unsigned
  80. C4244 - Conversion from 'type1' to 'type2', possible loss of data.
  81. C4251 - 'identifier' : class 'type' needs to have dll-interface to be used by
  82. clients of class 'type2'
  83. C4267 - Conversion from 'size_t' to 'type', possible loss of data.
  84. C4305 - 'identifier' : truncation from 'type1' to 'type2'
  85. C4355 - 'this' : used in base member initializer list
  86. C4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
  87. C4996 - 'function': was declared deprecated
  88. C4251 is of particular note, if you are compiling the Protocol Buffer library
  89. as a DLL (see previous section). The protocol buffer library uses templates in
  90. its public interfaces. MSVC does not provide any reasonable way to export
  91. template classes from a DLL. However, in practice, it appears that exporting
  92. templates is not necessary anyway. Since the complete definition of any
  93. template is available in the header files, anyone importing the DLL will just
  94. end up compiling instances of the templates into their own binary. The
  95. Protocol Buffer implementation does not rely on static template members being
  96. unique, so there should be no problem with this, but MSVC prints warning
  97. nevertheless. So, we disable it. Unfortunately, this warning will also be
  98. produced when compiling code which merely uses protocol buffers, meaning you
  99. may have to disable it in your code too.