Build libvyosconfig for Windows?

automation

#1

Is it possible to build libvyosconfig for Windows (with Cygwin)?

I’m working on an C# application that needs to generate VyOS configuration files. My goal is to create a .NET Standard library with bindings for VyOS ConfigTree.

I’ve got configtree.py working on an Ubuntu system. It only depends on libvyosconfig.so.0. But in order to use configtree.py on a Windows system, libvyosconfig has to be build for Windows.

The Makefile of libvyosconfig seems to be multiplatform, but I have no experience with OCaml.

Does anyone have suggestions for compiling libvyosconfig for Windows?
Should I try https://github.com/ocaml-cross/opam-cross-windows, OCaml for Windows or some other tool?


#2

This sample .NET Core application calls libvyosconfig.so.0 functions.

namespace ConfigTree
{
    class Program
    {
        static void Main(string[] args)
        {
            var config = Config.from_string("system { host-name vyos \n } interfaces { dummy dum0 { address 192.0.2.1/24 \n address 192.0.2.20/24 \n disable \n } }");
            Console.WriteLine("config* = " + config);
            var toStringResult = Config.to_string(config);
            Console.WriteLine("config.to_string(): " + toStringResult);
        }
    }
    public static class Config
    {
        [DllImport("libvyosconfig.so.0", CharSet = CharSet.Ansi)]
        public static extern IntPtr from_string(string s);
        [DllImport("libvyosconfig.so.0", CharSet = CharSet.Ansi)]
        public static extern string to_string(IntPtr self);
    }
}

It produces this output on Ubuntu (WSL):

config* = 26827648
config.to_string(): system {
    host-name "vyos"
}
interfaces {
    dummy dum0 {
        address "192.0.2.1/24"
        address "192.0.2.20/24"
        disable { }
    }
}

I want to do the same on the Windows platform, but don’t know how to build libvyosconfig.