Windows MSYS2 MinGW library names (.a vs. .lib)

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?

use -lgsl (without the lib prefix)


Thanks for the solution and pointer to the relevant code! I can confirm it works with -lgsl.

1 Like