Starting from this example i build C mylib.so library in order to call C API function.
I use lua5.4.4 building it on my own 'make mingw under msys2' and install it under msys2 /mingw32/bin, /include, etx.
I started from this sample code https://chsasank.com/lua-c-wrapping.html
Building it under msys2 with gcc -Wall-shared -fPIC -o mylib.so -I/mingw32/include mylib.c -llua
Then running ./libexample.lua with
#!/mingw32/bin/lua
package.cdpath = 'mylib'
local mylibtest = require 'mylib'
Getting output as this error loading module 'mylib' from 'mylib'