Given this C program:
#include <gsl/gsl_cdf.h>
#include <stdio.h>
int main(){
double bottom_tail = gsl_cdf_gaussian_P(-1.96, 1);
printf("Area betweeen [-1.96, 1.96]: %g\n", 1 - 2*bottom_tail);
}
I am able to compile it via
zig-dev build-exe .\main-gsl.c -target x86_64-windows-gnu -lc -llibgsl -I"c:\users\LeimgruberF\opt\msys64\mingw64\include" -L"c:\Users\LeimgruberF\opt\msys64\mingw64\lib"`
but only if I rename the library file to be linked from libgsl.a
to libgsl.lib
. So the actual question: is there a way for Zig to look for and accept *.a
library files even though -target x86_64-windows-gnu
looks for *.lib
library files per convention on Windows?
dimdin
February 9, 2024, 5:10pm
2
use -lgsl
(without the lib prefix)
try checked_paths.writer().print("\n {s}", .{test_path.items});
fs.cwd().access(test_path.items, .{}) catch |err| switch (err) {
error.FileNotFound => break :so,
else => |e| fatal("unable to search for so library '{s}': {s}", .{
test_path.items, @errorName(e),
}),
};
return true;
}
// In the case of MinGW, the main check will be .lib but we also need to
// look for `libfoo.a`.
if (target.isMinGW() and link_mode == .Static) mingw: {
test_path.clearRetainingCapacity();
try test_path.writer().print("{s}" ++ sep ++ "lib{s}.a", .{
lib_dir_path, lib_name,
});
try checked_paths.writer().print("\n {s}", .{test_path.items});
fs.cwd().access(test_path.items, .{}) catch |err| switch (err) {
error.FileNotFound => break :mingw,
else => |e| fatal("unable to search for static library '{s}': {s}", .{
2 Likes
Thanks for the solution and pointer to the relevant code! I can confirm it works with -lgsl
.
1 Like