ApolloAuto / apollo

An open autonomous driving platform
Apache License 2.0
25.04k stars 9.68k forks source link

cyber_core should not link gflag/glog/protobuf in linkopts directly. #7797

Closed luozhaohui closed 5 years ago

luozhaohui commented 5 years ago

Program crashed Program crashed because it linked to protobufes of different version.

 ldd box2d_test | grep "protobuf"
    libcyber_Smessage_Slibprotobuf_Ufactory.so => ~/.cache/bazel/_bazel_kesalin/14989fc4d6cc893e257bf3ebcca40484/execroot/gs_cyber/bazel-out/k8-fastbuild/bin/modules/common/math/./../../../_solib_k8/libcyber_Smessage_Slibprotobuf_Ufactory.so (0x00007f28c755b000)
    libexternal_Scom_Ugoogle_Uprotobuf_Slibprotobuf.so => ~/.cache/bazel/_bazel_kesalin/14989fc4d6cc893e257bf3ebcca40484/execroot/gs_cyber/bazel-out/k8-fastbuild/bin/modules/common/math/./../../../_solib_k8/libexternal_Scom_Ugoogle_Uprotobuf_Slibprotobuf.so (0x00007f28c689c000)
    libexternal_Scom_Ugoogle_Uprotobuf_Slibprotobuf_Ulite.so => ~/.cache/bazel/_bazel_kesalin/14989fc4d6cc893e257bf3ebcca40484/execroot/gs_cyber/bazel-out/k8-fastbuild/bin/modules/common/math/./../../../_solib_k8/libexternal_Scom_Ugoogle_Uprotobuf_Slibprotobuf_Ulite.so (0x00007f28c67f9000)
    libprotobuf.so.13 => /usr/local/lib/libprotobuf.so.13 (0x00007f28c6261000)
    libprotobuf.so.9 => /usr/lib/x86_64-linux-gnu/libprotobuf.so.9 (0x00007f28c3c96000)

Environment 1, Build apollo(master branch) without docker. 2, Have different protobufes installed.

Solution Build target 'cyber_core' should not link gflag/glog/protobuf in linkopts directly: file: cyber/BUILD

    linkopts = [
        "-lglog",
        "-lgflags",
        "-lprotobuf",
        "-luuid",
    ],

Please add them in 'deps'. file: cyber/BUILD

    deps = [
        "@fastrtps",
        "@gflags",
        "@glog",
        "@com_google_protobuf//:protobuf",
    ],
muleisheng commented 5 years ago

This may have some problems if version of -lprotobuf and "@com_google_protobuf//:protobuf" are different. Thanks