High Block Dev

Writing OBS plugin in Go

I utilize OBS for my podcasts, and I find it to be an exceptional software tool. Currently, I'm in the process of developing a plugin, and I'm considering using Go, given its compatibility with writing C code through cgo.

While cgo provides its own cross-platform compilation, I successfully managed to compile it on Windows using gcc. Here are the steps to follow:

1. Begin by cloning OBS under a specific folder using the command `git submodule add https://github.com/obsproject/obs-studio/ thirdparty/obs`. You can also include this in your `.gitmodules` file so that it's cloned alongside your main project.


[submodule "thirdparty/obs"]

path = thirdparty/obs

url = https://github.com/obsproject/obs-studio/

branch = 29.1.3


2. In your `main.go` file, include the following at the top:


// #cgo CFLAGS: -Ithirdparty/obs/libobs

// #cgo darwin LDFLAGS: -L. -lobs.0

// #cgo linux LDFLAGS: -L. -lobs

// #cgo windows LDFLAGS: -L. -lobs

// #include <obs-module.h>


3. Remember to copy `obs.dll` from the OBS installation folder and place it beside your Go file.

4. Install gcc for Windows from [https://jmeubank.github.io/tdm-gcc/](https://jmeubank.github.io/tdm-gcc/). In my experience, this version works best.

5. Finally, you can compile your Go file using the command `go build -buildmode=c-shared -o goplugin.dll`.

If you find this information helpful or have any questions, feel free to follow me at [http://x.com/thirdknife](http://x.com/thirdknife).


This version provides clearer instructions and organizes the steps for better readability. If you have any further requests or need additional improvements, feel free to let me know!

© 2023