hey, im trying to call lapacke from zig, however no matter what i do it just always segfaults. i have tried linking both openblas and whatever version void ships, and ive tried both my own code and this snippet: https://ziggit.dev/t/problem-calling-lapacke-from-zig/7321, which was successfully calling lapacke according to the thread. trying to get a backtrace from lldb:
(lldb) bt
* thread #1, name = 'lapack-test', stop reason = signal SIGSEGV: address not mapped to object (fault address: 0x0)
* frame #0: 0x0000000000000000
how i linked the library in my build.zig:
//lib_mod.addIncludePath(.{ .cwd_relative = "/usr/include/" });
//lib_mod.addLibraryPath(.{ .cwd_relative = "/usr/lib/" });
//lib_mod.linkSystemLibrary("lapacke", .{ .needed = true, });
//lib_mod.linkSystemLibrary("lapack", .{ .needed = true, });
lib_mod.addIncludePath(b.path("src/deps/OpenBLAS/lapack-netlib/LAPACKE/include"));
lib_mod.addObjectFile(b.path("src/deps/OpenBLAS/build/lib/libopenblas.a"));
how i used it:
const lapack = @cImport({
@cInclude("lapacke.h");
});
...
const cov_mat = [9]f64{
cov_xx, cov_xy, cov_xz,
cov_xy, cov_yy, cov_yz,
cov_xz, cov_yz, cov_zz,
};
const eigenval_arr: [3]f64 = undefined;
const success = lapack.LAPACKE_dsyev(
101, // row major
'V', // compute both eigenvalues and eigenvectors
'U', // use upper triangle of matrix
3, // matrix size
&cov_mat, // matrix input, eigenvector output gets stored here too
3, // leading dimension, == n
&eigenval_arr, // output buffer for eigenvalues
);
(+ the snippet from the link)