Location>code7788 >text

Compile and build under brpc linux

Popularity:304 ℃/2024-08-17 20:38:24

brpc compiles and builds under linux, which is a bit more complicated than under mac. mac can be compiled successfully by following the official instructions, and some configuration adjustments need to be made during the process.

Finalized brpc compilation via bazel on linux.

Related versions centos version 7, bazel version 2.0.0

brpc version 1.0, gflags, protobuf, leafldb related version due to network loading slow reason, through the download configuration to the local realization.

bazel WORKSPACE Configuration

workspace(name = "com_github_brpc_brpc")

load("@bazel_tools//tools/build_defs/repo:", "http_archive")

skylib_version = "0.8.0"
http_archive(
name = "bazel_skylib",
type = "",
url = "/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib.{}.".format (skylib_version, skylib_version),
sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e",
)

local_repository(
name = "rules_cc",
path = "/root/rules_cc-8bd6cd75d03c01bb82561a96d9c1f9f7157b13d0",
)

local_repository(
name = "rules_java",
path = "/root/rules_java-7cf3cefd652008d0a64a419c34c13bdca6c8f178",
)

local_repository(
name = "com_google_protobuf",
path = "/root/protobuf-3.6.1.3",
)


local_repository(
name = "com_github_gflags_gflags",
path = "/root/gflags-46f73f88b18aee341538c0dfc22b1710a6abedef",
)

bind(
name = "gflags",
actual = "@com_github_gflags_gflags//:gflags",
)

new_local_repository(
name = "com_github_google_leveldb",
path = "/root/leveldb-a53934a3ae1244679f812d998a4f16f2c7f309a6",
build_file = "//:",
)

 

http_archive(
name = "com_github_google_glog",
build_file = "//:",
strip_prefix = "glog-a6a166db069520dbbd653c97c2e5b12e08a8bb26",
url = "/google/glog/archive/"
)

http_archive(
name = "com_google_googletest",
strip_prefix = "googletest-0fe96607d85cf3a25ac40da369db62bbee2939a5",
url = "/google/googletest/archive/",
)

new_local_repository(
name = "openssl",
path = "/usr",
build_file = "//:",
)

new_local_repository(
name = "openssl_macos",
build_file = "//:",
path = "/usr/local/opt/openssl",
)

bind(
name = "ssl",
actual = "@openssl//:ssl"
)

bind(
name = "ssl_macos",
actual = "@openssl_macos//:ssl"
)

new_local_repository(
name = "zlib",
build_file = "//:",
path = "/usr",
)

Compile command

  brpc bazel compilation:

bazel build //:protoc-gen-mcpack --incompatible_disable_deprecated_attr_params=false --incompatible_new_actions_api=false 

echo_c++_server bazel compilation:

      bazel build //example:echo_c++_server --incompatible_disable_deprecated_attr_params=false --incompatible_new_actions_api=false --copt -DHAVE_ZLIB=1