Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)

When building a project on Windows using CMake, I got this error:

  Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)
Call Stack (most recent call first):
C:/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
C:/CMake/share/cmake-3.25/Modules/FindProtobuf.cmake:650 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake/protobuf.cmake:1 (find_package)
CMakeLists.txt:256 (include)

The solution is to build and install Protobuf yourself.

  1. download Protobuf source code, extract to a directory such as C:\Protobuf, create a build directory such as C:\Protobufbuild
  2. cmake -G Ninja -S C:\Protobuf -B C:\Protobufbuild -DCMAKE_INSTALL_PREFIX=C:\protobuf-21.12
  3. cd to C:\Protobufbuild and execute ninja install
  4. cmake -G Ninja -DProtobuf_LIBRARIES=C:\protobuf-21.12\lib -DProtobuf_INCLUDE_DIR=C:\protobuf-21.12\include -DCMAKE_INSTALL_PREFIX=C:\projectinstalldir -S C:\projectsourcedir -B C:\projectbuilddir

Note that don’t download and install the pre-built Protobuf binaries such as protoc-21.12-win64.zip  as Protocol Buffers official website tells you to do because some files such as whole libs and some include files are missing in the pre-built package.

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply