Closed IOMisaka closed 1 year ago
What version of Go are you using?
Does it help when you manually do a go get github.com/schollz/peerdiscovery
?
I have go1.20 installed, and the package peerdiscovery is already located in go/pkg/mod/github.com/schollz. I tried manually but got the same package version v1.7.0, it seems nothing changed. I can't find struct Peer nor AnnouncePayload in project and peerdiscovery. Where are they should be?
I just checked the go.mod file, should i downgrade go 1.20 to 1.18?
https://github.com/fzwoch/obs-teleport/blob/3650cbead84c4068948417449a83129f027f07e4/source.go#L45 https://github.com/fzwoch/obs-teleport/blob/3650cbead84c4068948417449a83129f027f07e4/types.go#L31
Go 1.20 should be fine.
I never used the Go tooling under Windows. So I have no idea what may be wrong.
You will need to change your command line to create a shared library instead of an application and give it header and library location of a jpeg
library via Go's cgo
system.
From the Go 1.20 changelog:
The go command now disables cgo by default on systems without a C toolchain. More specifically, when the CGO_ENABLED environment variable is unset, the CC environment variable is unset, and the default C compiler (typically clang or gcc) is not found in the path, CGO_ENABLED defaults to 0. As always, you can override the default by setting CGO_ENABLED explicitly.
The most important effect of the default change is that when Go is installed on a system without a C compiler, it will now use pure Go builds for packages in the standard library that use cgo, instead of using pre-distributed package archives (which have been removed, as noted above) or attempting to use cgo and failing. This makes Go work better in some minimal container environments as well as on macOS, where pre-distributed package archives have not been used for cgo-based packages since Go 1.16.
You will definitely need a C compiler for compiling, and perhaps explicitly enable the use of CGO.
Thank you, now I use mingw64 for cgo. After adding CGO_CPPFLAGS for jpeg-turbo, obs-frontend-api and libobs, now I'm likely stuck on utils.c. like other application, maybe I need something like ... obs plugin SDK? I try to include header path libobs from obs-studio sourcecode, but it doesn't work. go build -x prompt below:
Yes, you will need to link to obs.lib
, obs-frontend-api.lib
and jpeg.lib
(preferable from libjpeg-turbo).
Check upon https://pkg.go.dev/cmd/cgo for CGO_CFLAGS
and CGO_LDFLAGS
documentation.
Edit: I think since it is mingw, you can just link to the .dll
files. You don't need the import library.
Thanks, jpeg-turbo and CGO_LDFLAGS has set. Now I'm try to build obs.lib and obs-frontend-api.lib from obs source
You should be able to pick the .dll
files from your existing OBS installation.
Succeed! Converting dll to lib, that's amazing. Thanks for help. Here's my config for building on windows 11:
go1.20 64bit
, mingw64
and libjpeg-turbo-gcc64
.obs-studio\libobs
and obs-studio/UI/obs-frontend-api
.obs.lib
and obs-frontend-api.lib
. This is the tutorial for converting dll to lib. Beware of the NAME.def
, it will become the NAME.dll
the lib reference to.CGO_CPPFLAGS
, add header folders of libobs
and obs-frontend-api
and libjpeg-turbo-gcc64
.(go env
shows like set CGO_CPPFLAGS=-IC:\repos\obs-studio-28.1.2\libobs -IC:\repos\obs-studio-28.1.2\UI\obs-frontend-api -IC:\mingw64\libjpeg-turbo-gcc64\include
)CGO_LDFLAGS
, add lib folders of libobs
and obs-frontend-api
and libjpeg-turbo-gcc64
with -static
option.(It need an extra jpeg62.dll when publishing plugin without static link. go env
shows like set CGO_LDFLAGS=-LC:\mingw64\libjpeg-turbo-gcc64\lib -lobs -lobs-frontend-api -static
,I put obs.lib
and obs-frontend-api.lib
into mingw64\x86_64-w64-mingw32\lib
so here I just use -l
)go build -buildmode=c-shared -ldflags="-s -w"
in obs-teleport folder.I think you could have skipped step 3.
. An import library is only needed for the MSVC linker (which is not supported by CGO anyway). GCC and Clang are "smart" enough when you try to link to a .dll directly to read the .dll and create the required info themselves.
But it doesn't work when trying to use dlls directly.
Hm weird. But congrats anyway!
Hi, I need help to compile this project. When I run "go build", I got undefined errors on struct Peer and struct AnnouncePayload. Is there something I have missed? Sorry for bothering, I'm new to golang and running on Windows 11. Thanks.