Hi Bazel Cgo experts,
I am trying to build a go_binary that depends on
com_github_pebbe_zmq4, a go wrapper of the
libzmq in C++. I've been struggling to make pebbe/zmq4 "see" zmq.h in libzmq, and can't make it work after trying multiple approaches:
load("@rules_go//go:def.bzl", "go_binary")
go_binary(
name = "zmq_client",
srcs = ["zmq_client.go"],
deps = [
"@com_github_pebbe_zmq4//:go_default_library",
],
cgo = True,
cdeps = [
# Including the full library doesn't make it work, either.
# "@libzmq//:libzmq",
"@libzmq//:libzmq_headers_only",
],
)
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
load("@rules_go//go:def.bzl", "go_binary")
package(default_visibility = ["//visibility:public"])
# Dependency of cppzmq
cmake(
# Note: This exact name is required to make "cppzmq cmake target work.
name = "zmq",
# This uses Ninja to build under the hood, which is faster than make.
#generate_args = ["-GNinja"],
lib_source = "@zeromq//:all_srcs",
out_static_libs = ["libzmq.a"],
)
go_binary(
name = "zmq_client",
srcs = ["zmq_client.go"],
deps = [
"@com_github_pebbe_zmq4//:go_default_library",
],
cgo = True,
cdeps = [
":zmq",
],
)
What am I missing? I've read through go_binary and rules_foreign_cc docs multiple times but can't find the right way, also tried the Bazel Slack #Go channel
here, but haven't found out the solution yet, so would appreciate some guidance from Cgo experts. Thanks!