如何在引用共享库的“ cc_library”中使用“ alwayslink”?

时间:2019-07-10 19:08:02

标签: bazel

我在“ cc_library”中使用了“ alwayslink”标志,该标志引用了PCL共享库,因此在链接选项时,它被包裹在“ -Wl,-整个档案”和“ -Wl,-没有整个档案”中。 但是当我检查“ annotation_ui_tool-2.params”时,我看不到这种情况。 下面给出了WORKSPACE文件部分和“ annotation_ui_tool-2.params”文件的内容。

WORKSPACE:
new_local_repository (
    name = "pcl_lib_repo",
    path = "/usr/local/include/pcl-1.9",
    build_file_content = """
package(default_visibility = ["//visibility:public"])
cc_library(
    name = "pcl_lib",
    defines = ["DISABLE_PCAP", "DISABLE_PNG", "DISABLE_LIBUSB_1_0", "DISABLE_QHULL"],
    includes = ["."],
    hdrs = glob([ "pcl/**/*.h", "pcl/**/*.hpp"]),
    alwayslink = True,
    linkopts = [
        "-L/usr/local/lib",
        "-lpcl_common",
        "-lpcl_io",
        "-lpcl_kdtree",
        "-lpcl_search",
        "-lpcl_visualization",
    ],
    visibility = ["//visibility:public"],
)
""",
)

annotation_ui_tool-2.params:

-o
bazel-out/k8-dbg/bin/annotation_ui_tool
-fuse-ld=gold
-Wl,-no-as-needed
-Wl,-z,relro,-z,now
-B/usr/bin
-pass-exit-codes
-lstdc++
-lm
-Wl,-whole-archive
bazel-out/k8-dbg/bin/_objs/annotation_ui_tool/pcd_viewer.pic.o
-Wl,-no-whole-archive
-Wl,-whole-archive
external/doxlib_libs/libdoxlib-d.a
-Wl,-no-whole-archive
-shared
-L/usr/local/lib
-lpcl_common
-lpcl_io
-lpcl_kdtree
-lpcl_search
-lpcl_visualization

0 个答案:

没有答案