[PR #24] [CLOSED] visual studio support (again) #601

Open
opened 2026-01-29 20:46:22 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/google/brotli/pull/24
Author: @anthrotype
Created: 2/15/2015
Status: Closed

Base: masterHead: win_build_4


📝 Commits (5)

  • d3369ea deprecated rand_r() calls removed();
  • 8dfd549 removed endian.h: port.h already contains macros for endianness
  • 2fd7dac [port.h] define Windows byte order macros (assume little-endian)
  • aac0729 [python/setup.py] use relative paths instead of symlinks (unsupported on Win)
  • f49421f add python's build and dist directories to .gitignore

📊 Changes

9 files changed (+59 additions, -55 deletions)

View changed files

📝 .gitignore (+2 -0)
📝 enc/block_splitter.cc (+4 -2)
📝 enc/fast_log.h (+2 -1)
📝 enc/port.h (+5 -0)
📝 enc/write_bits.h (+0 -5)
📝 python/brotlimodule.cc (+2 -2)
python/dec (+0 -1)
python/enc (+0 -1)
📝 python/setup.py (+44 -43)

📄 Description

this pull request is the same as @r-lyeh request #5 from October last year, with just some little modifications of mine.

There are three problems when trying to compile the C++ brotli encoder with Microsoft Visual C++ 12.0:

  • "fast_log.h" is missing the assert header include:

    enc/fast_log.h(44) : error C3861: 'assert': identifier not found

  • the use of function rand_r() inside "block_splitter.cc" makes the compiler raise "identifier not found". As @r-lyeh suggested, rand_r could be replaced by a combination of srand() and rand().

    enc/block_splitter.cc(100) : error C3861: 'rand_r': identifier not found

  • in "write_bits.h", the attempt to import "endian.h" fails on Windows, which unfortunately does not provide this header. Besides, the include does not seem to be necessary here. In fact, the macro "IS_LITTLE_ENDIAN" which is used in write_bits.h is already specified inside "port.h" header, which is among the includes.

    enc/write_bits.h(24) : fatal error C1083: Cannot open include file: 'endian.h': No such file or directory

As a workaround, @r-lyeh proposed a new portable "endian.h" header file. However, for the sake of detecting the byte order, I believe it would be sufficient to presume that when _WIN32 (or _WIN64) is defined, then the byte order will always little endian (ok, the XBox 360 has a big endian processor, but...).
So I added such Windows-specific #ifdef to "port.h", and removed @r-lyeh's "endian.h" file.

I would like to emphasize that it's only by using the patch by @r-lyeh (with or without the superfluous endian.h) that I was able compile the brotli Python extension on the Windows platform.

I have tested both gcc (via Cygwin or MinGW) and several Microsoft Visual C/C++ compilers.

Cygwin's gcc (POSIX) was able to compile only through @r-lyeh patch.

The MinGW-w64 gcc (targeting win32) was not able to compile even when using @r-lyeh's patch, so I gave up on gcc and tried one of MS Visual Studio compilers.

I first tried MS Visual Studio 2008 (the same used for Windows Python 2.7), but it was missing stdint.h header...

So I tried to force Python's distutils to use Visual Studio 2010. This time stdint.h was found, but the math.h module was missing the binary logarithm (log2) function... (of course, that could be rewritten as log(v)/log(2) or something).

Finally, I tried to make Python use MS Visual Studio 2013 as a compiler, and this time the Python extension compiled correctly, again thanks to @r-lyeh patch.

The brotli decoder (which is written in plain C) does compile successfully on Windows. It is the encoder, written in modern C++, which has the above mentioned issues. It would be nice if you could add Windows among the supported platforms. I'm interested because we are trying to use the brotli Python bindings in fontTools for decoding/encoding WOFF2.

Thanks a lot for your work.

Cosimo


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/google/brotli/pull/24 **Author:** [@anthrotype](https://github.com/anthrotype) **Created:** 2/15/2015 **Status:** ❌ Closed **Base:** `master` ← **Head:** `win_build_4` --- ### 📝 Commits (5) - [`d3369ea`](https://github.com/google/brotli/commit/d3369ea96c69cc3ba9bff0677232c1dde0eb8b3e) deprecated rand_r() calls removed(); - [`8dfd549`](https://github.com/google/brotli/commit/8dfd5491c58d3ed6aa5cbd2d118a2376de1e358d) removed endian.h: port.h already contains macros for endianness - [`2fd7dac`](https://github.com/google/brotli/commit/2fd7dac79ff735aa7a14e6fc3f6f8c51eb58bc4f) [port.h] define Windows byte order macros (assume little-endian) - [`aac0729`](https://github.com/google/brotli/commit/aac07290bee46acf5b9ee7821aeddf3b78f4ef70) [python/setup.py] use relative paths instead of symlinks (unsupported on Win) - [`f49421f`](https://github.com/google/brotli/commit/f49421f19a498c9a61e5f97805fc2a64f01d5081) add python's build and dist directories to .gitignore ### 📊 Changes **9 files changed** (+59 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+2 -0) 📝 `enc/block_splitter.cc` (+4 -2) 📝 `enc/fast_log.h` (+2 -1) 📝 `enc/port.h` (+5 -0) 📝 `enc/write_bits.h` (+0 -5) 📝 `python/brotlimodule.cc` (+2 -2) ➖ `python/dec` (+0 -1) ➖ `python/enc` (+0 -1) 📝 `python/setup.py` (+44 -43) </details> ### 📄 Description this pull request is the same as @r-lyeh request #5 from October last year, with just some little modifications of mine. There are three problems when trying to compile the C++ brotli encoder with Microsoft Visual C++ 12.0: - "fast_log.h" is missing the assert header include: enc/fast_log.h(44) : error C3861: 'assert': identifier not found - the use of function rand_r() inside "block_splitter.cc" makes the compiler raise "identifier not found". As @r-lyeh suggested, rand_r could be replaced by a combination of srand() and rand(). enc/block_splitter.cc(100) : error C3861: 'rand_r': identifier not found - in "write_bits.h", the attempt to import "endian.h" fails on Windows, which unfortunately does not provide this header. Besides, the include does not seem to be necessary here. In fact, the macro "IS_LITTLE_ENDIAN" which is used in write_bits.h is already specified inside "port.h" header, which is among the includes. enc/write_bits.h(24) : fatal error C1083: Cannot open include file: 'endian.h': No such file or directory As a workaround, @r-lyeh proposed a new portable "endian.h" header file. However, for the sake of detecting the byte order, I believe it would be sufficient to presume that when _WIN32 (or _WIN64) is defined, then the byte order will always little endian (ok, the XBox 360 has a big endian processor, but...). So I added such Windows-specific #ifdef to "port.h", and removed @r-lyeh's "endian.h" file. I would like to emphasize that it's only by using the patch by @r-lyeh (with or without the superfluous endian.h) that I was able compile the brotli Python extension on the Windows platform. I have tested both gcc (via Cygwin or MinGW) and several Microsoft Visual C/C++ compilers. Cygwin's gcc (POSIX) was able to compile only through @r-lyeh patch. The MinGW-w64 gcc (targeting win32) was not able to compile even when using @r-lyeh's patch, so I gave up on gcc and tried one of MS Visual Studio compilers. I first tried MS Visual Studio 2008 (the same used for Windows Python 2.7), but it was missing stdint.h header... So I tried to force Python's distutils to use Visual Studio 2010. This time stdint.h was found, but the math.h module was missing the binary logarithm (log2) function... (of course, that could be rewritten as log(v)/log(2) or something). Finally, I tried to make Python use MS Visual Studio 2013 as a compiler, and this time the Python extension compiled correctly, again thanks to @r-lyeh patch. The brotli decoder (which is written in plain C) does compile successfully on Windows. It is the encoder, written in modern C++, which has the above mentioned issues. It would be nice if you could add Windows among the supported platforms. I'm interested because we are trying to use the brotli Python bindings in fontTools for decoding/encoding WOFF2. Thanks a lot for your work. Cosimo --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 20:46:22 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#601