Trying to use a dylib in go program

Hello Gophers

I’m trying to use a dynamic library generated by a library called CIMGUI (https://github.com/Extrawurst/cimgui), it’s a C binding from an another library (IMGUI) written in C++. it’s really awesome and I would like to use it golang. I had made several tries in order to get this working but it’s really hard for me as I a noob in the C , C++ and Go worlds. I had already try it with swig with no success and now I’m trying another approach trying to use the dylib that is compiled in the library.

Well , the library has a makefile that generates the dylib , so my question then is how can I use the this dynamic library in a go package ?

I’ve tried something like this:

package main

//is this ok ?
//cgo LDFLAGS: cimgui.dylib

//this headers are necessary if the dylib is loaded?
//#include ../imgui/imgui.h 
//#include ./cimgui.h

import "C"

func main() {

}

best regards

Remove empty line between includes and ‘import “C”’. It won’t work otherwise.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.