Hello,
I have been using Bazel and have been trying to use Protocol Buffers in
C++. I’ve reproduced my issue using a small amount of code:
car.proto
————————
syntax = "proto3";
message Car {
int32 wheels = 1;
}
I then compiled this using protoc (v3.0.0) to produce car.pb.h and
car.pb.cc.
main.cc:
————————
#include <fstream>
#include "car.pb.h"
int main(void) {
Car car;
car.set_wheels(10);
std::fstream f ("~/Desktop/car.pb");
car.SerializeToOstream(&f);
}
BUILD:
————————
cc_binary(
name = "main",
srcs = ["main.cc"],
deps = [":car_pb"],
)
cc_library(
name = "car_pb",
srcs = ["car.pb.cc"],
hdrs = ["car.pb.h"],
deps = [],
)
bazel build :main runs fine, but then when I run bazel-bin/main I get:
dyld: Symbol not found: __ZN6google8protobuf7Message20DiscardUnknownFieldsEv
Referenced from: /Users/devankuleindiren/Desktop/PBTest/bazel-bin/main
Expected in: flat namespace
in /Users/devankuleindiren/Desktop/PBTest/bazel-bin/main
Abort trap: 6
I understand that this is a dynamic linking issue, but I don’t know whether
it’s because I’m using Bazel incorrectly, because I’ve installed protocol
buffers incorrectly or because of something else?
I’m running macOS Sierra 10.12.1. Also, I’ve tried setting
DYLD_LIBRARY_PATH to /usr/local/lib (where the libprotobuf libraries seem
to be installed).
Thanks,
Devan
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.