Installing protobuf on windows

Как установить protobuf на Windows? (Win7x64 / MinGW)

C ++ — Protobuf не компилируется в VS2012. Теперь я хочу использовать MinGW для компиляции на Windows. Может кто-нибудь, пожалуйста, дайте мне краткое описание того, как скомпилировать protobuf на Win7 x64. Я уже установил MinGW с установщиком графического интерфейса. Google пишет как уведомление об установке MinGW, что я должен обратиться к примечаниям по установке Unix. Но я не могу понять, как использовать автоматические инструменты на окнах.

редактировать

Хорошо, это то, что я сделал до сих пор:

minGW32-make.exe запускается без ошибок, но тесты не выполняются, и я не могу найти libprotobuf.lib. Есть некоторые libprotobuf.dll, но мне нужна библиотека, не так ли?

Решение

У вас должна быть консоль MSys вместе с вашей установкой MinGW. Эта консоль предоставляет Linux-подобную среду, в которой вы сможете нормально использовать автоинструменты.

Если MSys не установлен, вы также можете загрузить его с сайта MinGW.

cd в свой каталог с исходниками и попробуйте обычные:

Некоторые библиотеки вызывают проблемы в Windows, но большинство хорошо компилируется с MinGW и MSys. Вернитесь и добавьте больше информации к своему вопросу, если столкнетесь с конкретными проблемами.

minGW32-make.exe запускается без ошибок, но тесты не выполняются, и я не могу найти libprotobuf.lib. Есть некоторые libprotobuf.dll, но мне нужна библиотека, не так ли?

Обычно для динамической библиотеки вы получите protobuf.dll (динамическая библиотека) и libprotobuf.a (библиотека статических оболочек).

При ссылке просто пройдите -lprotobuf компоновщику — он будет искать оба libprotobuf.a а также protobuf.lib ,

( .lib это другой формат статической библиотеки, который частично обрабатывается MinGW, но не является родным.)

Другие решения

Вы не будете работать с .lib файл при использовании набора инструментов MinGW. Вместо этого вы можете ссылаться на DLL напрямую. MinGW Wiki объясняет это .

Я мог бы получить dll и lib оба. Это когда вам не нужен статический файл lib и вы хотите использовать dll и файл lib.
Вам необходимо внести следующие изменения в код Protobuf:

    Откройте проект в VS. Или любой другой редактор. Я использую VS2015.

В настройках проекта libProtoBuf, в препроцессоре C / C ++ добавьте следующие флаги.
PROTOBUF_USE_DLLS; LIBPROTOBUF_EXPORTS;
Эти флаги будут экспортировать информацию из profobuf, используя dllexport

в коде клиента, где вы используете Protobuf, определите: PROTOBUF_USE_DLLS. Который сделает protobuf включающим использование dllimport.

Читайте также:  Как отключить залипание мыши windows 10

Выполнив шаг 2, вы увидите как dll, так и lib в вашей выходной папке. В противном случае вы всегда будете видеть только dll, а не файл lib.

Надеюсь это поможет. Если нет, пожалуйста, напишите здесь сообщение, и я могу помочь вам разобраться с этим.

Protocol Buffer Compiler Installation

How to install the protocol buffer compiler.

Protocol Buffer Compiler Installation

While not mandatory, gRPC applications often leverage Protocol Buffers for service definitions and data serialization. Most of the example code from this site uses version 3 of the protocol buffer language (proto3) .

The protocol buffer compiler, protoc , is used to compile .proto files, which contain service and message definitions. Choose one of the methods given below to install protoc .

Install using a package manager

You can install the protocol compiler, protoc , with a package manager under Linux or macOS using the following commands.

Warning

Check the version of protoc (as indicated below) after installation to ensure that it is sufficiently recent. The versions of protoc installed by some package managers can be quite dated.

Installing from pre-compiled binaries, as indicated in the next section, is the best way to ensure that you’re using the latest release of protoc .

Linux, using apt or apt-get , for example:

Install pre-compiled binaries (any OS)

To install the latest release of the protocol compiler from pre-compiled binaries, follow these instructions:

Manually download from github.com/google/protobuf/releases the zip file corresponding to your operating system and computer architecture ( protoc- — .zip ), or fetch the file using commands such as the following:

Unzip the file under $HOME/.local or a directory of your choice. For example:

Update your environment’s path variable to include the path to the protoc executable. For example:

Other installation options

If you’d like to build the protocol compiler from sources, or access older versions of the pre-compiled binaries, see Download Protocol Buffers .

Protoc / Protobuf Installation on Windows

Required to generate make file

Jan 22, 2019 · 3 min read

To work with GoLang micro services i was installing protobuf which is a library to create make files, to implement GRPC in use, but there was several challenges when i started installation over windows 10. Will add for Linux and Mac later , but they are very easy to install on both machine’s by console.

At the end finally i found a solution that wa s very simple , easy and relevant to finish the installation within few steps. First of all don’t get confused with so many documentation from the github protobuf installation page, this is good to know the details but if you just started then it’s not for you because it’s time taking and will create lot’s of confusion that could be also a hurdle in implementing GRPC stuff at beginning level.

Читайте также:  Ноутбук samsung не ставится windows

It’s a very good stuff to use a RPC service to interchanging data internally between multiple services in binary , that give us a boost and reason to use micro services very smoothly .

Now here is the steps to install on windows , Linux / Mac

|Prerequisite: Check you have a working visual studio code with c++ on your local windows system, because this will make your installation more easier.

To the windows users:

you can clone this anywhere on your local system , but i will recommend you to put this inside of C:/ , will make easier in accessing and execution to commands.

first of all clone below vcpkg library to install rest of the dependencies:

after cloning this repository go to the vcpkg directory

After that if you want to test all the commands then use

Later that you can see all the available commands , but you have to run the below bootstrapper command to boot this installation :

After executing this command you should integrate this vcpkg with you system config to execute globally, so that execute the below command:

now we can install protoc / protobuf to generate make files, so that we need to execute below command , one more thing to take care, if you know the exact windows os version then use below command

`vcpkg install protobuf protobuf:x64-windows `

if you have any confusion then only execute below command , personally i also recommend to execute this because that will handle all the default requirements as per your local machine.

To test the instillation on your local system , you need to run this command:

output should look like this something , could be little different on your system:

`protobuf:x86-windows 3.6.1.3–1 Protocol Buffers — Google’s data interchange format`

Hope you are able to achieve the job successfully.

How to install protobuf on windows? (Win7x64/MinGW)

C++-Protobuf does not compile in VS2012. Now I want to use MinGW to compile it on windows. Can someone please give me some brief headwords on how to compile protobuf on Win7 x64. I already installed MinGW with the GUI installer. Google writes as MinGW setup notice that I should refer to the Unix installation notes. But I cant figure out how to use the auto tools on windows.

Edit

Okay this is what I’ve done until now:

minGW32-make.exe runs without errors, but no tests are running and I cant find libprotobuf.lib. There are some libprotobuf.dll but I need the lib, dont I?.

Читайте также:  Linux права для создаваемых файлов

3 Answers 3

You should have an MSys console together with your MinGW instalation. This console provides an linux-like environment in which you should be able to use autotools normally.

If MSys is not installed, you can grab it from the MinGW site too.

cd to your directory with sources and try the usual:

Some libraries cause problems on Windows but most compile well with MinGW and MSys. Come back and add more info to your question if you run into specific problems.

minGW32-make.exe runs without errors, but no tests are running and I cant find libprotobuf.lib. There are some libprotobuf.dll but I need the lib, dont I?.

Usually for a dynamic library you’d get protobuf.dll (the dynamic library) and libprotobuf.a (the static wrapper library).

When linking, just pass -lprotobuf to the linker — it will look for both libprotobuf.a and protobuf.lib .

( .lib is another static library format, which is partially handled by MinGW but not native here.)

Install and use Protocol Buffers for Java on Windows

The documentation for using Google Protobuf for Java in Windows environment is not very friendly, scattered and puts the new user into confusion. Here is a small attempt to assist the new explorers.

2 Answers 2

  1. Download the Win32 binary from https://github.com/google/protobuf/releases — At the time of writing, the latest is v3.3.0 and hence appropriate binary is https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-win32.zip
  2. Extract this zip file into a directory and add the bin directory under this into the system path environment variable.
  3. Checkout the source code from Github repository — As v3.3.0 is the latest release, checkout the same tag rather than master.
  4. Copy protoc.exe from step 1 and paste it under src directory in the checked out location.
  5. Continue to run maven tasks as provided here — https://github.com/google/protobuf/tree/master/java

To run the examples in the library —

    Copy the protoc.exe from step 1 above to a preferred location and ensure that location is added into the Path environment variable. To ensure it is done properly, open a new command prompt and run protoc —version to see the appropriate version you installed.

Create the Java package for protocol format given with the examples — defined in addressbook.proto as explained here — protoc -I=$SRC_DIR —java_out=$DST_DIR $SRC_DIR/addressbook.proto — This generates the required AddressBookProtos class under the package com.example.tutorial which is required for compiling the example code.

Once the generated code is in the example classpath, the code can be executed.

As a simpler approach, especially for occasional users, you could also just:

Оцените статью