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.
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.
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", )
The approxmvbb.BUILD
file looks like this
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"],
)
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"],
)
The source code for the binary 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.
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!!