Compilation and installation of grpc on window
Compilation and installation of grpc on window
1.Git download source code
Source code address: https://github.com/grpc/grpc
First go to the official website to learn how to install it. Official website: https://grpc.io/Select
C++ to enter.
The interface also says that it teaches us how to quickly start building a grpc project in C++ language.
But it's all about how Linux is built.
We can see how to clone the source code:
As shown in the figure: the source code and submodules (third-party code) are cloned. We can modify it and clone the latest one without specifying the version.
git clone --recurse-submodules https://github.com/grpc/grpc
Copied latest source code information. When I cloned the source code of grpc, it was fine. I could clone it all, but it was a little slow. When cloning submodules, we often encounter failures. At this time, we only need to update our submodules.
git submodule update --init
Until we enter this line of code and run it directly, it means that our submodule has been cloned.
The complete source code is shown in the figure:
The source code in the third party is as shown in the figure:
The source code is ready.
Note: Be sure to ensure that the source code is complete, because the source code is also quite large, and missing things will cause problems in our subsequent compilation and generation.
2.CMake
Install CMake. Needless to say what CMake is. To put it simply, it is a tool that can help us build a project. It can help us associate the files required for complex projects and build a project management.
CMake's official website: https://cmake.org/Choose
to download and choose the corresponding one according to your own needs.
I chose to decompress it directly. After decompression, as shown in the picture:
Enter the bin directory and you can see:
You can install the bin you installed Once the directory is configured in the system environment, you can use the command line.
After installing CMake. Use CMake to build this project
1. Open the interface tool cmke-gui.exe
as the picture shows:
2. Select the folder of the source code you downloaded
3. Create a new folder to store the generated binary files
4. Click to install
Waiting to be generated.
After configuring these, you can generate the corresponding number of project files according to your needs.
5 click to generate
Once generated, it's done.
6Click to open the project
The project file will be opened in vs.
3.vs compilation and generation
Now that we have entered the vs interface, we can see that 134 projects are loaded in our solution, then select ALL_BUILD to generate all projects, right-click and select Generate. Note that when generating, you must choose the CMake selection (x64 or win32) to match the one
in vs , otherwise it will fail.
The entire generation time is very long, about 20 minutes. After successful generation.
Find the INSTALL project, right-click, use it only for the project, and build it only.
After building, I can find the files we used for the project in the build directory we set earlier in CMake. If the information is not modified, it defaults to the grpc folder in C:\Program Files (x86). The file is as shown:
You can enter the bin directory, call cmd, and check the protoc information. This will be used later. The version information seems to be very important.
The entire compilation process is quite cumbersome, and it takes a long time to wait for the next third-party file. After I have time, I am writing how to call grpc in Qt.