我正在编写一个简单的 Bazel BUILD 文件,但我必须包含 MKL 库。我的 main.c 包括这个库:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "omp.h"
#include "mkl.h"
#include "mkl_types.h"
#include "mkl_dfti.h"
位于由模块环境设置的 $MKLROOT 中的最后 3 个库。我的 bazel 构建文件是:
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
cc_library(
name = "mkl_headers",
srcs = glob(["include/*(.cc|.cpp|.cxx|.c++|.C|.c|.h|.hh|.hpp|.ipp|.hxx|.inc|.S|.s|.asm|.a|.lib|.pic.a|.lo|.lo.lib|.pic.lo|.so|.dylib|.dll|.o|.obj|.pic.o)"]),
includes = ["include"],
visibility = ["//visibility:public"],
)
cc_library(
name = "mkl_libs_linux",
srcs = [
"lib/libiomp5.so",
"lib/libmklml_intel.so",
],
visibility = ["//visibility:public"],
)
cc_binary(
name = "mklfft",
srcs = ["main.c"],
deps = [
":mkl_libs_linux"
],
)
我试图从 BUILD tensorflow mkl 文件中举一个例子,但它非常复杂。
bazel 构建命令返回:
INFO: Analyzed target //mklfft:mklfft (2 packages loaded, 8 targets configured).
INFO: Found 1 target...
ERROR: missing input file 'mklfft/mkl.h', owner: '//mklfft:mkl.h'
ERROR: missing input file 'mklfft/mkl_dfti.h', owner: '//mklfft:mkl_dfti.h'
ERROR: missing input file 'mklfft/mkl_types.h', owner: '//mklfft:mkl_types.h'
ERROR: /C/mklfft/BUILD:6:1: //mklfft:mkl: missing input file '//mklfft:mkl.h'
ERROR: /C/mklfft/BUILD:6:1: //mklfft:mkl: missing input file '//mklfft:mkl_dfti.h'
ERROR: /C/mklfft/BUILD:6:1: //mklfft:mkl: missing input file '//mklfft:mkl_types.h'
ERROR: missing input file 'mklfft/readFile.c', owner: '//mklfft:readFile.c'
Target //mklfft:mklfft failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /C/mklfft/BUILD:6:1 3 input file(s) do not exist
INFO: Elapsed time: 0.342s, Critical Path: 0.03s
INFO: 0 processes.
您能否阐明将外部共享库与 bazel 链接的方法?