andlabs / ui

Platform-native GUI library for Go.
Other
8.34k stars 647 forks source link

dynamic library support #358

Closed nowind closed 5 years ago

nowind commented 5 years ago

may it support link to libui dynamic library?

andlabs commented 5 years ago

To be honest, dynamic-only would be ideal, though it wouldn't be particularly Go-like. I would need to introduce a new build tag to support this, though. And then you would need to remember to copy the dynamic libraries into your program when doing go build.

If you want to do this locally, then you can change the #cgo directives to ONLY link to the libui dynamic library, and then copy those files to the ui directory in your GOPATH/src.

nowind commented 5 years ago

so,i need do following (windows):

  1. clone libui
  2. build with --out-implib libui_windows_dyn.a
  3. add new tag (maybe dynlib) as build tag
  4. add line "// +build !dynlib" in link_windows_386.go
  5. copy link_windows_386.go to link_dyn_windows_386.go & change !dynlib to dynlib & change // #cgo LDFLAGS: ${SRCDIR}/libui_windows_386.a to // #cgo LDFLAGS: ${SRCDIR}/libui_windows_dyn.a
  6. build with -tags dynlib
andlabs commented 5 years ago

I'm not sure about the implib part. You could probably just use the release MinGW DLLs directly.

nowind commented 5 years ago

emm,mingwgcc can link DLLs directly ,implib is not necessary