pkujhd / goloader

load and run golang code at runtime.
Apache License 2.0
497 stars 58 forks source link

Failed to execute plugin which contains dependency `unresolve external:<...>` #88

Closed DanijelRadakovic closed 1 year ago

DanijelRadakovic commented 1 year ago

I am using go-loader as my plugin system. The plugin that I want to use is available here. I build the object file with following commands as is described in the docs:

go list -export -f '{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}' std \
  $(go list -f '{{.Imports}}' ./... \
  | awk '{sub(/^\[/, ""); print }' \
  | awk '{sub(/\]$/, ""); print }') > importcfg
find . -name "*.go" -type f -print | xargs go tool compile -importcfg importcfg -o ethereum.o

I tried to use that object file in my other project but am I getting the following error:

go build main.go
./main

unresolve external:github.com/ethereum/go-ethereum/ethclient.(*Client).NetworkID

System information:

eh-steve commented 1 year ago

Hi, have you tried building/loading a JIT package using my fork https://github.com/eh-steve/goloader ?

pkujhd commented 1 year ago

I am using go-loader as my plugin system. The plugin that I want to use is available here. I build the object file with following commands as is described in the docs:

pkujhd/goloader branch not support for obj file with cgo. you can try eh-steve/goloader branch

unresolve external:github.com/ethereum/go-ethereum/ethclient.(*Client).NetworkID you use a .o not package main, so you need set path for goloader