gpt4 book ai didi

c++ - 我如何为 cc_library 添加默认的 copts,如 '-fopenmp'?

转载 作者:太空宇宙 更新时间:2023-11-04 12:41:35 24 4
gpt4 key购买 nike

https://docs.bazel.build/versions/master/be/c-cpp.html

关于科普特人选项:

Each string in this attribute is added in the given order to COPTS before compiling the binary target. The flags take effect only for compiling this target, not its dependencies, so be careful about header files included elsewhere. All paths should be relative to the workspace, not to the current package.

cc_library(
name = 'lib1',
srcs = glob([
'src/*.cpp',
]),
hdrs = glob([
'include/*.h',
'include/**/*.h',
]),
copts = [
'-std=c++11',
'-fopenmp',
'-march=native',
],
)

cc_binary(
name = "test1",
srcs = ["tests/test1.cpp"],
deps = [
":lib1",
],
copts = [
'-std=c++11',
'-fopenmp',
'-march=native',
],
)

如果我删除 test1 规则中的科普特人,编译将失败。如何修改 lib1 规则,使依赖于它的所有规则也可以编译。

最佳答案

您还需要将 linkopts = ["-lgomp"] 添加到您的 cc_binary 规则。

关于c++ - 我如何为 cc_library 添加默认的 copts,如 '-fopenmp'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53954613/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com