Haivision / srtgo

Go bindings for SRT. Advantages of SRT technology for an easy to use programming language
Mozilla Public License 2.0
185 stars 52 forks source link

Building on windows #42

Closed campbellwmorgan closed 2 years ago

campbellwmorgan commented 2 years ago

I've written some code using this library which works brilliantly on linux, but I'm having some serious problems building it on Windows.

I've managed to build SRT fine and after a big struggle, I have managed to configure the lib and include folders correctly so that mingw64 can read them, however i'm getting the following error when running go build on my project:

# github.com/haivision/srtgo
..\..\vendor\github.com\haivision\srtgo\netutils.go:25:7: undefined: unix.AF_INET6
..\..\vendor\github.com\haivision\srtgo\netutils.go:30:7: undefined: unix.AF_INET
..\..\vendor\github.com\haivision\srtgo\netutils.go:56:57: undefined: syscall.SizeofSockaddrInet4
..\..\vendor\github.com\haivision\srtgo\netutils.go:69:57: undefined: syscall.SizeofSockaddrInet6
..\..\vendor\github.com\haivision\srtgo\srtgo.go:232:17: undefined: syscall.SizeofSockaddrAny

I don't know enough about the unix or syscall packages to know whether these can be called from windows at all. Am I making a build configuration mistake or is it simply that this library has not been written with windows in mind?

Many thanks in advance!

Edit: To give some context

OS: Windows 10 Go Version: 1.17.1 Pacman version v6.0.1 Libsrt tag v1.4.3 Gcc (Rev5, Built by MSYS2 project) 10.3.0 (via mingw64)

campbellwmorgan commented 2 years ago

I've been digging a bit further, and the parts of the syscall package which are undefined here (https://cs.opensource.google/go/go/+/refs/tags/go1.17.1:src/syscall/ztypes_linux_amd64.go;l=311) have the following header

//go:build amd64 && linux
// +build amd64,linux

which makes me think that without modification, this library will never build on windows.

gizahNL commented 2 years ago

Try to build (& test) with the code from my branch, it's a bit of a hack, but it should hopefully work ;)

jeoliva commented 2 years ago

Fixed in #43