I found a much simpler and cleaner solution without involving any ldflags
and without using
--export-all-symbols
In my main.go (or whatever main package that contains the main func):
/*
#cgo LDFLAGS: ${SRCDIR}/main.def
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x0001;
__de
For anyone who wants to build a windows .exe with go-sdl2 and opengl, and
has an optimus driver, and wants to ensure that
the high performance gpu is selected by default for their final product, I
will document my findings here
I found the followingsolution, which can be proven that it work