second-state / WasmEdge-go

The GO language SDK and API for WasmEdge
https://www.secondstate.io/articles/extend-golang-app-with-webassembly-rust/
Apache License 2.0
107 stars 16 forks source link

Cannot find header file when running helloworld example #45

Closed purplefox closed 4 months ago

purplefox commented 4 months ago

Hi, I am attempting to run a HelloWorld example based on https://github.com/second-state/WasmEdge-go-examples/tree/master/go_Accumulate

I have installed wasmedge as per the instructions and when running from my IDE (goland) I get:

../../../go/pkg/mod/github.com/second-state/!wasm!edge-go@v0.13.0/wasmedge/ast.go:3:11: fatal error: 'wasmedge/wasmedge.h' file not found
 #include <wasmedge/wasmedge.h>
          ^~~~~~~~~~~~~~~~~~~~~
1 error generated.

I can see that wasmedge.h exists in the directory ~/.wasmedge/include/wasmedge.

Presumably there is some kind of environment variable or build flag I need to provide so it uses the correct include path to find the header file?

purplefox commented 4 months ago

The exact code I am running is here:

https://gist.github.com/purplefox/d37c4593dac8d8e73767001f99d637f6

I installed wasmedge with:

wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.13.0
purplefox commented 4 months ago

I figured out that there is a bunch of env vars that need to be setup by sourcing .wasmedge/env. I was following the "getting started" instructions on the README here https://github.com/second-state/WasmEdge-go/blob/master/README.md which don't mention this needs to be sourced.