使用包中工作空间导入的线性代数库Eigen
Using the linear algebra library Eigen imported by the workspace in a package
我正在使用 Bazel(版本 0.25.2)。
我有以下目录结构(一个名为 EigenDemo
的主文件夹和一个名为 Core
的包含一些文件的子文件夹):
EigenDemo
|-Core
| |- BUILD
| |- main.cpp
|- eigen.BUILD
|- WORKSPACE
文件内容如下所示:
Core/main.cpp
#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2, 2);
m(0, 0) = 3;
m(1, 0) = 2.5;
m(0, 1) = -1;
m(1, 1) = m(1, 0) + m(0, 1);
std::cout << m << std::endl;
}
工作空间
workspace(name = "EigenDemo")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Eigen
http_archive(
name = "eigen",
build_file = "//:eigen.BUILD",
sha256 = "3a66f9bfce85aff39bc255d5a341f87336ec6f5911e8d816dd4a3fdc500f8acf",
url = "https://bitbucket.org/eigen/eigen/get/c5e90d9.tar.gz",
strip_prefix="eigen-eigen-c5e90d9e764e"
)
Core/BUILD
cc_binary(
name = "EigenDemo",
srcs = ["main.cpp"],
copts = ["-Iexternal/eigen"],
deps = [
"@eigen",
],
)
eigen.BUILD(我用的是tensorflow提供的那个)
当我尝试构建 (bazel build //...
) 时,出现以下错误:
PS E:\dev\BazelDemos\EigenDemo> bazel build //...
Starting local Bazel server and connecting to it...
INFO: An error occurred during the fetch of repository 'eigen'
INFO: Call stack for the definition of repository 'eigen':
- E:/dev/bazeldemos/eigendemo/WORKSPACE:6:1
INFO: Repository 'eigen' used the following cache hits instead of downloading the corresponding file.
* Hash '3a66f9bfce85aff39bc255d5a341f87336ec6f5911e8d816dd4a3fdc500f8acf' for https://bitbucket.org/eigen/eigen/get/c5e90d9.tar.gz
If the definition of 'eigen' was updated, verify that the hashes were also updated.
ERROR: E:/dev/bazeldemos/eigendemo/Core/BUILD:1:1: no such package '@eigen//': Traceback (most recent call last):
File "C:/users/admin/_bazel_admin/u7yxnnij/external/bazel_tools/tools/build_defs/repo/http.bzl", line 56
workspace_and_buildfile(ctx)
File "C:/users/admin/_bazel_admin/u7yxnnij/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 64, in workspace_and_buildfile
ctx.symlink(ctx.attr.build_file, "BUILD.bazel")
Unable to load package for //:eigen.BUILD: BUILD file not found in any of the following directories.
- E:/dev/bazeldemos/eigendemo and referenced by '//Core:EigenTest'
ERROR: Analysis of target '//Core:EigenTest' failed; build aborted: no such package '@eigen//': Traceback (most recent call last):
File "C:/users/admin/_bazel_admin/u7yxnnij/external/bazel_tools/tools/build_defs/repo/http.bzl", line 56
workspace_and_buildfile(ctx)
File "C:/users/admin/_bazel_admin/u7yxnnij/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 64, in workspace_and_buildfile
ctx.symlink(ctx.attr.build_file, "BUILD.bazel")
Unable to load package for //:eigen.BUILD: BUILD file not found in any of the following directories.
- E:/dev/bazeldemos/eigendemo
INFO: Elapsed time: 10.959s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (9 packages loaded, 33 targets configured)
当我将所有文件放在一个文件夹中时,一切正常。我想我必须更改 BUILD 文件中的 deps
字段:
deps = [
"@eigen",
],
但我不知道如何("//:eigen"
不起作用)。
将一个空的 BUILD 文件添加到 EigenDemo
目录:
EigenDemo
|-Core
| |- BUILD
| |- main.cpp
|- BUILD <-------------------- New empty BUILD file
|- eigen.BUILD
|- WORKSPACE
我正在使用 Bazel(版本 0.25.2)。
我有以下目录结构(一个名为 EigenDemo
的主文件夹和一个名为 Core
的包含一些文件的子文件夹):
EigenDemo
|-Core
| |- BUILD
| |- main.cpp
|- eigen.BUILD
|- WORKSPACE
文件内容如下所示:
Core/main.cpp
#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2, 2);
m(0, 0) = 3;
m(1, 0) = 2.5;
m(0, 1) = -1;
m(1, 1) = m(1, 0) + m(0, 1);
std::cout << m << std::endl;
}
工作空间
workspace(name = "EigenDemo")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Eigen
http_archive(
name = "eigen",
build_file = "//:eigen.BUILD",
sha256 = "3a66f9bfce85aff39bc255d5a341f87336ec6f5911e8d816dd4a3fdc500f8acf",
url = "https://bitbucket.org/eigen/eigen/get/c5e90d9.tar.gz",
strip_prefix="eigen-eigen-c5e90d9e764e"
)
Core/BUILD
cc_binary(
name = "EigenDemo",
srcs = ["main.cpp"],
copts = ["-Iexternal/eigen"],
deps = [
"@eigen",
],
)
eigen.BUILD(我用的是tensorflow提供的那个)
当我尝试构建 (bazel build //...
) 时,出现以下错误:
PS E:\dev\BazelDemos\EigenDemo> bazel build //...
Starting local Bazel server and connecting to it...
INFO: An error occurred during the fetch of repository 'eigen'
INFO: Call stack for the definition of repository 'eigen':
- E:/dev/bazeldemos/eigendemo/WORKSPACE:6:1
INFO: Repository 'eigen' used the following cache hits instead of downloading the corresponding file.
* Hash '3a66f9bfce85aff39bc255d5a341f87336ec6f5911e8d816dd4a3fdc500f8acf' for https://bitbucket.org/eigen/eigen/get/c5e90d9.tar.gz
If the definition of 'eigen' was updated, verify that the hashes were also updated.
ERROR: E:/dev/bazeldemos/eigendemo/Core/BUILD:1:1: no such package '@eigen//': Traceback (most recent call last):
File "C:/users/admin/_bazel_admin/u7yxnnij/external/bazel_tools/tools/build_defs/repo/http.bzl", line 56
workspace_and_buildfile(ctx)
File "C:/users/admin/_bazel_admin/u7yxnnij/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 64, in workspace_and_buildfile
ctx.symlink(ctx.attr.build_file, "BUILD.bazel")
Unable to load package for //:eigen.BUILD: BUILD file not found in any of the following directories.
- E:/dev/bazeldemos/eigendemo and referenced by '//Core:EigenTest'
ERROR: Analysis of target '//Core:EigenTest' failed; build aborted: no such package '@eigen//': Traceback (most recent call last):
File "C:/users/admin/_bazel_admin/u7yxnnij/external/bazel_tools/tools/build_defs/repo/http.bzl", line 56
workspace_and_buildfile(ctx)
File "C:/users/admin/_bazel_admin/u7yxnnij/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 64, in workspace_and_buildfile
ctx.symlink(ctx.attr.build_file, "BUILD.bazel")
Unable to load package for //:eigen.BUILD: BUILD file not found in any of the following directories.
- E:/dev/bazeldemos/eigendemo
INFO: Elapsed time: 10.959s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (9 packages loaded, 33 targets configured)
当我将所有文件放在一个文件夹中时,一切正常。我想我必须更改 BUILD 文件中的 deps
字段:
deps = [
"@eigen",
],
但我不知道如何("//:eigen"
不起作用)。
将一个空的 BUILD 文件添加到 EigenDemo
目录:
EigenDemo
|-Core
| |- BUILD
| |- main.cpp
|- BUILD <-------------------- New empty BUILD file
|- eigen.BUILD
|- WORKSPACE