{"id":1100,"date":"2024-07-30T09:46:46","date_gmt":"2024-07-30T01:46:46","guid":{"rendered":"http:\/\/zkeeer.space\/?p=1100"},"modified":"2024-07-31T09:11:13","modified_gmt":"2024-07-31T01:11:13","slug":"%e5%9c%a8centos-6-%e4%b8%8a%e7%bc%96%e8%af%91-grpc","status":"publish","type":"post","link":"http:\/\/zkeeer.space\/?p=1100","title":{"rendered":"\u5728CentOS 6 \u4e0a\u7f16\u8bd1 gRPC-1.65.1"},"content":{"rendered":"<h1>\u5728CentOS 6 \u4e0a\u7f16\u8bd1 gRPC-1.65.1<\/h1>\n<h2>\u524d\u63d0\u6761\u4ef6<\/h2>\n<p>\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86\u4ee5\u4e0b\u8f6f\u4ef6\u5305\uff1a<\/p>\n<ul>\n<li>Git<\/li>\n<li>CMake<\/li>\n<li>GCC \u548c G++<\/li>\n<li>\u5fc5\u8981\u7684\u5f00\u53d1\u5de5\u5177\u548c\u5e93<\/li>\n<\/ul>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u9879\uff1a<\/p>\n<pre><code>sudo yum install -y epel-release\r\nsudo yum install -y cmake gcc-c++ git autoconf automake libtool make\r\n<\/code><\/pre>\n<h3>Install openssl (to use instead of boringssl)<\/h3>\n<p>download openssl-1.0.2k (\u540ccentos7.9\u7684openssl\u7248\u672c)\uff1a<br \/>\nwget https:\/\/codeload.github.com\/openssl\/openssl\/tar.gz\/refs\/tags\/OpenSSL_1_0_2k<br \/>\n\u7f16\u8bd1openssl-1.0.2k:<\/p>\n<pre><code>tar zxvf openssl-OpenSSL_1_0_2k.tar.gz\r\ncd openssl-OpenSSL_1_0_2k\r\n.\/config --prefix=\/path\/to\/openssl-1.0.2k --shared\r\nmake &amp;&amp; make install\r\n<\/code><\/pre>\n<h2>\u6b65\u9aa4 1\uff1a\u514b\u9686 gRPC \u4ed3\u5e93<\/h2>\n<p>\u9996\u5148\uff0c\u514b\u9686 gRPC \u4ed3\u5e93\u5e76\u5207\u6362\u5230\u7279\u5b9a\u7248\u672c\uff08\u4f8b\u5982 <code>v1.65.1<\/code>\uff09\uff1a<\/p>\n<pre><code># \u514b\u9686 gRPC \u4ed3\u5e93\r\ngit clone https:\/\/github.com\/grpc\/grpc.git\r\ncd grpc\r\n\r\n# \u5207\u6362\u5230\u7279\u5b9a\u7684 tag\r\ngit checkout v1.65.1\r\n\r\n# \u521d\u59cb\u5316\u5e76\u66f4\u65b0\u6240\u6709\u5b50\u6a21\u5757\r\ngit submodule update --init --recursive\r\n<\/code><\/pre>\n<h2>\u6b65\u9aa4 2\uff1a\u914d\u7f6e\u548c\u7f16\u8bd1 gRPC<\/h2>\n<p>\u521b\u5efa\u4e00\u4e2a\u6784\u5efa\u76ee\u5f55\u5e76\u4f7f\u7528 CMake \u914d\u7f6e\u7f16\u8bd1\u73af\u5883\uff1a<\/p>\n<pre><code># \u521b\u5efa\u6784\u5efa\u76ee\u5f55\r\nmkdir -p cmake\/build\r\ncd cmake\/build\r\n\r\n# \u8fd0\u884c CMake \u914d\u7f6e\r\ncmake ..\/.. -DgRPC_INSTALL=ON -DCMAKE_BUILD_TYPE=Release -DgRPC_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DgRPC_SSL_PROVIDER=package -DCMAKE_INSTALL_PREFIX=\/path\/to\/grpc -DABSL_PROPAGATE_CXX_STD=ON -DOPENSSL_ROOT_DIR=\/path\/to\/openssl-1.0.2k\r\n# \u9700\u8981\u7f16\u8bd1\u52a8\u6001\u5e93\uff0c\u6dfb\u52a0\u53c2\u6570 -DBUILD_SHARED_LIBS=ON\r\n# \u9700\u8981\u7f16\u8bd1Debug\/Release\u7248\u672c\uff0c\u6dfb\u52a0\u53c2\u6570 -DCMAKE_BUILD_TYPE=Debug\/Release\r\n# -DgRPC_SSL_PROVIDER=package \u9009\u9879\u662f\u4e3a\u4e86\u4f7f\u7528\u7cfb\u7edf\u5b89\u88c5ssl lib\uff0c\u5728centos6\u4e0a\u9700\u8981\u7f16\u8bd1\u66f4\u9ad8\u7248\u672c\u7684openssl\uff0c\u5efa\u8bae\u662f1.2.0k\u540ccentos7.9\u7684openssl\u7248\u672c\u4e00\u81f4\r\n# -DOPENSSL_ROOT_DIR=\/path\/to\/openssl-1.0.2k \uff0c\u4e0a\u9762\u7f16\u8bd1\u5b89\u88c5\u7684openssl-1.0.2k\u7684\u4f4d\u7f6e\r\n<\/code><\/pre>\n<p>\u7f16\u8bd1\u5e76\u5b89\u88c5 gRPC\uff1a<\/p>\n<pre><code># \u7f16\u8bd1 gRPC\r\nmake -j16\r\n\r\n# \u5b89\u88c5 gRPC\r\nmake install\r\n<\/code><\/pre>\n<h2>\u9a8c\u8bc1\u5b89\u88c5<\/h2>\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u9a8c\u8bc1 gRPC \u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<pre><code># \u68c0\u67e5\u5e93\u6587\u4ef6\r\nls \/path\/to\/grpc\/lib64\r\n<\/code><\/pre>\n<h2>\u5e38\u89c1\u95ee\u9898<\/h2>\n<h3>\u95ee\u9898 1\uff1a<code>gRPC_ABSL_PROVIDER is module but ABSL_ROOT_DIR is wrong<\/code><\/h3>\n<pre><code>\r\nDependency management\r\n\r\ngRPC's CMake build system has two options for handling dependencies. CMake can build the dependencies for you, or it can search for libraries that are already installed on your system and use them to build gRPC.\r\n\r\nThis behavior is controlled by the gRPC_&lt;depname&gt;_PROVIDER CMake variables, e.g. gRPC_CARES_PROVIDER. The options that these variables take are as follows:\r\nmodule - build dependencies alongside gRPC. The source code is obtained from gRPC's git submodules.\r\npackage - use external copies of dependencies that are already available on your system. These could come from your system package manager, or perhaps you pre-installed them using CMake with the CMAKE_INSTALL_PREFIX option.\r\n\r\nFor example, if you set gRPC_CARES_PROVIDER=module, then CMake will build c-ares before building gRPC. On the other hand, if you set gRPC_CARES_PROVIDER=package, then CMake will search for a copy of c-ares that's already installed on your system and use it to build gRPC.\r\n<\/code><\/pre>\n<p>\u57fa\u4e8e\u4ee5\u4e0a\u5b98\u7f51\u5bf9\u4e8e\u7b2c\u4e09\u65b9\u4f9d\u8d56\u7684\u89e3\u91ca\uff0c\u8fd9\u91cc\u9700\u8981\u4e0b\u8f7d\u6e90\u7801\u5e76\u4f7f\u7528module\u6a21\u5f0f\u3002<br \/>\n\u5982\u679c\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u9047\u5230\u8fd9\u4e2a\u9519\u8bef\uff0c\u8bf7\u786e\u4fdd\u4f60\u5df2\u7ecf\u6b63\u786e\u521d\u59cb\u5316\u548c\u66f4\u65b0\u4e86\u6240\u6709\u5b50\u6a21\u5757\u3002<\/p>\n<pre><code>git submodule update --init --recursive\r\n<\/code><\/pre>\n<h3>\u95ee\u9898 2\uff1a\u5982\u4f55\u786e\u8ba4\u662f\u5426\u5207\u6362\u5230\u4e86 <code>v1.65.1<\/code> \u8fd9\u4e2a tag\uff1f<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u7684 tag\uff1a<\/p>\n<pre><code># \u67e5\u770b\u5f53\u524d\u72b6\u6001\r\ngit status\r\n\r\n# \u67e5\u770b\u5f53\u524d commit \u7684\u8be6\u7ec6\u4fe1\u606f\r\ngit show\r\n\r\n# \u4f7f\u7528 git describe \u67e5\u770b\u5f53\u524d tag\r\ngit describe --tags\r\n<\/code><\/pre>\n<p>\u4f60\u5e94\u8be5\u770b\u5230\u7c7b\u4f3c <code>HEAD detached at v1.65.1<\/code> \u7684\u8f93\u51fa\u3002<\/p>\n<h3>\u95ee\u9898 3: invalid conversion from const uint8_t to unsigned char in include\/grpc\/impl\/slice_type.h<\/h3>\n<p>\u4f9d\u8d56\u9ad8\u7248\u672copenssl\u5bfc\u81f4\u7684\u95ee\u9898\uff0c\u5347\u7ea7\u5b8c\u6ca1\u6709\u51fa\u73b0<\/p>\n<h2>\u5b8c\u6574\u7684\u811a\u672c<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5305\u542b\u6240\u6709\u6b65\u9aa4\u7684\u5b8c\u6574\u811a\u672c\uff0c\u53ef\u4ee5\u590d\u5236\u5e76\u8fd0\u884c\uff1a<\/p>\n<pre><code>#!\/bin\/bash\r\n\r\n# \u5b89\u88c5\u4f9d\u8d56\r\nsudo yum install -y epel-release\r\nsudo yum install -y cmake gcc-c++ git autoconf automake libtool make\r\n\r\n# download openssl-1.0.2k (\u540ccentos7.9\u7684openssl\u7248\u672c)\uff1a\r\nwget https:\/\/codeload.github.com\/openssl\/openssl\/tar.gz\/refs\/tags\/OpenSSL_1_0_2k\r\n#\u7f16\u8bd1openssl-1.0.2k:\r\ntar zxvf openssl-OpenSSL_1_0_2k.tar.gz\r\ncd openssl-OpenSSL_1_0_2k\r\n.\/config --prefix=\/path\/to\/openssl-1.0.2k --shared\r\nmake &amp;&amp; make install\r\n\r\n\r\n# \u514b\u9686 gRPC \u4ed3\u5e93\r\ngit clone https:\/\/github.com\/grpc\/grpc.git\r\ncd grpc\r\n\r\n# \u5207\u6362\u5230\u7279\u5b9a\u7684 tag\r\ngit checkout v1.65.1\r\n\r\n# \u521d\u59cb\u5316\u5e76\u66f4\u65b0\u6240\u6709\u5b50\u6a21\u5757\r\ngit submodule update --init --recursive\r\n\r\n# \u521b\u5efa\u6784\u5efa\u76ee\u5f55\r\nmkdir -p cmake\/build\r\ncd cmake\/build\r\n\r\n# \u8fd0\u884c CMake \u914d\u7f6e\r\ncmake ..\/.. -DgRPC_INSTALL=ON -DCMAKE_BUILD_TYPE=Release -DgRPC_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DgRPC_SSL_PROVIDER=package -DCMAKE_INSTALL_PREFIX=\/path\/to\/grpc -DABSL_PROPAGATE_CXX_STD=ON -DOPENSSL_ROOT_DIR=\/path\/to\/openssl-1.0.2k\r\n\r\n# \u7f16\u8bd1 gRPC\r\nmake -j16\r\n\r\n# \u5b89\u88c5 gRPC\r\nmake install\r\n\r\n# \u9a8c\u8bc1\u5b89\u88c5\r\nls \/path\/to\/grpc\/lib64\r\n<\/code><\/pre>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u5728 CentOS 6 \u4e0a\u6210\u529f\u7f16\u8bd1\u5e76\u5b89\u88c5 gRPC\u3002\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u9879\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\uff0c\u5e76\u6309\u7167\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\u3002\u5982\u679c\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u53c2\u8003\u6587\u6863\u4e2d\u7684\u5e38\u89c1\u95ee\u9898\u90e8\u5206\u8fdb\u884c\u6392\u67e5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Arm CentOS 6 \u4e0a\u7f16\u8bd1 gRPC<br \/>\n\u524d\u63d0\u6761\u4ef6<br \/>\n\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86\u4ee5\u4e0b\u8f6f\u4ef6\u5305\uff1a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,77],"tags":[114,115],"_links":{"self":[{"href":"http:\/\/zkeeer.space\/index.php?rest_route=\/wp\/v2\/posts\/1100"}],"collection":[{"href":"http:\/\/zkeeer.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zkeeer.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zkeeer.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zkeeer.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1100"}],"version-history":[{"count":5,"href":"http:\/\/zkeeer.space\/index.php?rest_route=\/wp\/v2\/posts\/1100\/revisions"}],"predecessor-version":[{"id":1106,"href":"http:\/\/zkeeer.space\/index.php?rest_route=\/wp\/v2\/posts\/1100\/revisions\/1106"}],"wp:attachment":[{"href":"http:\/\/zkeeer.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zkeeer.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1100"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zkeeer.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}