On Mon, Nov 14, 2016, 9:28 AM ebw <e...@boese-wolf.eu> wrote:

> Hi!
>
> I tried to come up with a way to write plugins in go for a C host
> application using -buildmode=c-shared.
>
> My first try failed, because
>
> go build -buildmode=c-shared
>
>
> insisted to resolve all symbols. I thought I could leave some symbols
> unresolved, so they can be later
> resolved, when the shared library is opened by the host application with
> dlopen.
>
> I tweaked the commands in the output of
>
> go build -buildmode=c-shared
>
>
> a bit and now it works.
>
> But I am unsure wether I am headed for a train wreck later. I assume the
> behavior of go build -buildmode=c-shared
> was selected with great care.
>
> I have a complete example at
>
> https://github.com/erwo42/golang-dlopen-plugin
>
> I don't know, how to make such an example work with the playground, so
> please go out of your way and look
> at the repo.
>
> If you see problems with this, please let me know.
>
> Yours sincerely,
>
> Eric Wolf
>

I had been down a similar path where I was trying to port a go library to
C++ via building a c-shared library and then delegating to it from a thin
C++ API. Turned out I hit problems with it in practice, in related to
static thread local storage model, as well as signal handling conflicts in
the host app. I ended up having to ditch it and port to pure C++ so that my
C++ users could use it in a large shared host application (lots of plugins)

> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to