I'm writing a simple Bazel BUILD file but I have to include MKL library. My main.c include this library:
#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"
The last 3 libs that are located in $MKLROOT set by a module environment. My bazel build file is:
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"
],
)
I tried to take an example from the BUILD tensorflow mkl file but it's very complicated.
The bazel build command return:
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.
Can you clarify the method to link external shared libraries with bazel?