bazel立即运行分段错误 [英] bazel run immediately Segmentation faults

查看:138
本文介绍了bazel立即运行分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在现有的bazel项目中使用本地构建的软件包().它的bazel构建没有任何错误,但是当我尝试执行bazel运行时,它立即出现段错误.我尝试在调试模式下构建它,但是当我在调试模式下运行它时,它仍然会立即出现段错误,而没有任何有用的错误消息.

I am trying to use a locally built package (this one) within an existing bazel project. It bazel builds without any errors, but when I try to bazel run it, it immediately segfaults. I tried building it in debug mode, but when I run it in debug mode it still immediately segfaults without any useful error message.

我按照自述文件中的说明构建了外部软件包,示例运行良好(在bazel之外),所以我知道外部库不是问题.

I built the external package following the instructions in the README and the examples run fine (outside of bazel), so I know that the external libraries are not the issue.

我创建了一个存储库以访问我的WORKSPACE文件中的此程序包

I made a repository to access this package in my WORKSPACE file

new_local_repository(
    name = "ApproxMVBB",
    path = "/absolute/path/to/ApproxMVBB",
    build_file = "approxmvbb.BUILD", )

approxmvbb.BUILD文件如下所示

cc_library(
    name = "ApproxMVBB-lib",
    srcs = glob(["**/*.a"])+glob(["**/*.so"]),
    hdrs = glob(["**/*.hpp"]),
    includes = ["include", "build/include", "external/Diameter/include", "external/GeometryPredicates/include"],
    visibility = ["//visibility:public"],
)

我正在尝试运行的cc_binary看起来像这样

And the cc_binary I am trying to run looks like this

cc_binary(
    name = "TestMVBB",
    srcs = [
        "src/test_approxmvbb.cpp",
    ],
    deps = [
        "@ApproxMVBB//:ApproxMVBB-lib",
    ],
    linkopts = ["-shared"],
)

二进制文件src/test_approvmvbb.cpp

#include <iostream>
#include "ApproxMVBB/ComputeApproxMVBB.hpp"

int  main(int argc, char** argv)
{
      ApproxMVBB::Matrix3Dyn points(3,10000);
      points.setRandom();
      ApproxMVBB::OOBB oobb = ApproxMVBB::approximateMVBB(points,0.001,500,5,0,5);
      oobb.expandToMinExtentRelative(0.1);
      return 0;
}

推荐答案

我发现了自己的错误.首先,我做了很多更改,忘记了重建外部程序包,所以这些库不存在...哎呀.

I found my mistakes. First, I was changing a lot of things and forgot to rebuild the external package, so the libraries didn't exist... oops.

但是更重要的是,在构建外部软件包时,它输出的库文件的文件扩展名不是.o.so,因此我不得不在cc_library目标中更改以下行

But more importantly, when the external package is built, it outputs library files that have file extensions other than .o and .so so I had to change the following line in the cc_library target

srcs = glob(["**/*.a"])+glob(["**/*.so"])+glob(["**/*.so.2.1.1"]),

希望这对以后的人有帮助!

Hope this helps someone in the future!!

这篇关于bazel立即运行分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆