如何在大多数静态模式(linkstatic=1)下静态链接系统库?我试着使用"-Wl,-Bstatic -lboost_thread -Wl,-Bdynamic“或者"-Wl,-Bstatic","-lboost_thread","-Wl,-Bdynamic",但是他们都不起作用。我不想在系统中硬编码libboost_thread.a的路径。
cc_binary( name = "main", srcs = [ "main.cpp", linkopts = [ "-lboost_thread", )
boost_thread库作为动态库进行链接。
ldd bazel-bin/main linux-vdso.so.1 libboost_thread.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0 libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ...
发布于 2021-06-10 23:23:19
基于此问题中的答案 Telling gcc directly to link a library statically ,"-l:libboost_thread.a“将静态链接系统库,而无需在系统中对libboost_thread.a的路径进行硬编码。
cc_binary( name = "main", srcs = [ "main.cpp",