共享库是cc_binary:
cc_binary(
name = "libfoo.so",
srcs = ["foo.cc"],
linkshared = 1, ## important
)
Run Code Online (Sandbox Code Playgroud)
(在重要的情况下,您可能还应该添加linkstatic = 1一个独立的 DSO,该 DSO 本身不具有对其源依赖项的加载时依赖项。)
小智 5
为了执行动态链接,必须首先导入共享库。您应该指定库标头、库二进制文件和接口库(仅 Windows 需要,本示例中不存在):
# Build the shared library
cc_binary(
name = "libfoo.so",
srcs = ["foo.cc"],
linkshared = 1, ## important
)
# Import the shared library
cc_import(
name = "imported_libfoo",
hdrs = ["foo.h"],
shared_library = "libfoo.so",
)
# Link to the shared library
cc_binary(
name = "bar",
deps = [":imported_libfoo"],
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3775 次 |
| 最近记录: |