[GH-ISSUE #356] Undefined symbols during go build #25918

Closed
opened 2026-04-22 01:46:11 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @drusepth on GitHub (Aug 15, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/356

Trying to build on a fresh Ubuntu 22 instance:

ubuntu@machine:~/ollama$ go version
go version go1.21.0 linux/amd64

ubuntu@machine:~/ollama$ go build .
go: downloading github.com/chzyer/readline v1.5.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/olekukonko/tablewriter v0.0.5
go: downloading github.com/spf13/cobra v1.7.0
go: downloading golang.org/x/crypto v0.10.0
go: downloading github.com/mattn/go-runewidth v0.0.14
go: downloading github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
go: downloading golang.org/x/term v0.10.0
go: downloading github.com/gin-contrib/cors v1.4.0
go: downloading github.com/gin-gonic/gin v1.9.1
go: downloading gonum.org/v1/gonum v0.13.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/rivo/uniseg v0.2.0
go: downloading golang.org/x/sys v0.10.0
go: downloading github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
go: downloading github.com/gin-contrib/sse v0.1.0
go: downloading github.com/mattn/go-isatty v0.0.19
go: downloading golang.org/x/net v0.10.0
go: downloading github.com/go-playground/validator/v10 v10.14.0
go: downloading github.com/pelletier/go-toml/v2 v2.0.8
go: downloading github.com/ugorji/go/codec v1.2.11
go: downloading google.golang.org/protobuf v1.30.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/gabriel-vasile/mimetype v1.4.2
go: downloading github.com/go-playground/universal-translator v0.18.1
go: downloading github.com/leodido/go-urn v1.2.4
go: downloading golang.org/x/text v0.10.0
go: downloading github.com/go-playground/locales v0.14.1
# github.com/jmorganca/ollama/llm
llm/ggml.go:49:2: undefined: llamaHyperparameters
llm/ggml.go:177:34: ggml.NumLayer undefined (type GGML has no field or method NumLayer)
llm/llm.go:38:14: ggml.FileType undefined (type *GGML has no field or method FileType)
llm/llm.go:70:10: undefined: newLlama

ubuntu@machine:~/ollama$ go build .
# github.com/jmorganca/ollama/llm
llm/ggml.go:49:2: undefined: llamaHyperparameters
llm/ggml.go:177:34: ggml.NumLayer undefined (type GGML has no field or method NumLayer)
llm/llm.go:38:14: ggml.FileType undefined (type *GGML has no field or method FileType)
llm/llm.go:70:10: undefined: newLlama

ubuntu@machine:~/ollama$ ls
Dockerfile  README.md  app  docs      format  go.sum  main.go  progressbar  server
LICENSE     api        cmd  examples  go.mod  llm     parser   scripts      vector

Happy to provide any other info that would be helpful. I didn't see any install instructions other than just building from source so I feel like I'm probably just missing a dependency or something. Any assistance would be much appreciated!

Originally created by @drusepth on GitHub (Aug 15, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/356 Trying to build on a fresh Ubuntu 22 instance: ```console ubuntu@machine:~/ollama$ go version go version go1.21.0 linux/amd64 ubuntu@machine:~/ollama$ go build . go: downloading github.com/chzyer/readline v1.5.1 go: downloading github.com/dustin/go-humanize v1.0.1 go: downloading github.com/olekukonko/tablewriter v0.0.5 go: downloading github.com/spf13/cobra v1.7.0 go: downloading golang.org/x/crypto v0.10.0 go: downloading github.com/mattn/go-runewidth v0.0.14 go: downloading github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db go: downloading golang.org/x/term v0.10.0 go: downloading github.com/gin-contrib/cors v1.4.0 go: downloading github.com/gin-gonic/gin v1.9.1 go: downloading gonum.org/v1/gonum v0.13.0 go: downloading github.com/spf13/pflag v1.0.5 go: downloading github.com/rivo/uniseg v0.2.0 go: downloading golang.org/x/sys v0.10.0 go: downloading github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 go: downloading github.com/gin-contrib/sse v0.1.0 go: downloading github.com/mattn/go-isatty v0.0.19 go: downloading golang.org/x/net v0.10.0 go: downloading github.com/go-playground/validator/v10 v10.14.0 go: downloading github.com/pelletier/go-toml/v2 v2.0.8 go: downloading github.com/ugorji/go/codec v1.2.11 go: downloading google.golang.org/protobuf v1.30.0 go: downloading gopkg.in/yaml.v3 v3.0.1 go: downloading github.com/gabriel-vasile/mimetype v1.4.2 go: downloading github.com/go-playground/universal-translator v0.18.1 go: downloading github.com/leodido/go-urn v1.2.4 go: downloading golang.org/x/text v0.10.0 go: downloading github.com/go-playground/locales v0.14.1 # github.com/jmorganca/ollama/llm llm/ggml.go:49:2: undefined: llamaHyperparameters llm/ggml.go:177:34: ggml.NumLayer undefined (type GGML has no field or method NumLayer) llm/llm.go:38:14: ggml.FileType undefined (type *GGML has no field or method FileType) llm/llm.go:70:10: undefined: newLlama ubuntu@machine:~/ollama$ go build . # github.com/jmorganca/ollama/llm llm/ggml.go:49:2: undefined: llamaHyperparameters llm/ggml.go:177:34: ggml.NumLayer undefined (type GGML has no field or method NumLayer) llm/llm.go:38:14: ggml.FileType undefined (type *GGML has no field or method FileType) llm/llm.go:70:10: undefined: newLlama ubuntu@machine:~/ollama$ ls Dockerfile README.md app docs format go.sum main.go progressbar server LICENSE api cmd examples go.mod llm parser scripts vector ``` Happy to provide any other info that would be helpful. I didn't see any install instructions other than just building from source so I feel like I'm probably just missing a dependency or something. Any assistance would be much appreciated!
Author
Owner

@jmorganca commented on GitHub (Aug 15, 2023):

Hi @drusepth which version of Go are you using? Thanks for creating an issue

<!-- gh-comment-id:1679747753 --> @jmorganca commented on GitHub (Aug 15, 2023): Hi @drusepth which version of Go are you using? Thanks for creating an issue
Author
Owner

@drusepth commented on GitHub (Aug 15, 2023):

Hey @jmorganca, I'm running go version go1.21.0 linux/amd64. Is there a different version I should be using? Thank you for your help!

<!-- gh-comment-id:1679748901 --> @drusepth commented on GitHub (Aug 15, 2023): Hey @jmorganca, I'm running `go version go1.21.0 linux/amd64`. Is there a different version I should be using? Thank you for your help!
Author
Owner

@jmorganca commented on GitHub (Aug 16, 2023):

D'oh! It was right there at the top of your issue. Sorry! Will look into this

<!-- gh-comment-id:1679781615 --> @jmorganca commented on GitHub (Aug 16, 2023): D'oh! It was right there at the top of your issue. Sorry! Will look into this
Author
Owner

@jmorganca commented on GitHub (Aug 16, 2023):

This may be from building without cgo:

CGO_ENABLED go build .

You may need to install gcc/g++:

sudo apt install build-essential
<!-- gh-comment-id:1679784144 --> @jmorganca commented on GitHub (Aug 16, 2023): This may be from building without cgo: ``` CGO_ENABLED go build . ``` You may need to install gcc/g++: ``` sudo apt install build-essential ```
Author
Owner

@drusepth commented on GitHub (Aug 16, 2023):

Hey, thanks so much. I think it was just that I needed build-essential; it wouldn't build with just CGO_ENABLED, but built just fine with it after also installing build-essential for gcc. Thanks a ton for your help!

Including another console log for posterity toward anyone finding this issue in the future. :)

ubuntu@machine:~/ollama$ CGO_ENABLED go build .
CGO_ENABLED: command not found

ubuntu@machine:~/ollama$ CGO_ENABLED=1 go build .
# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH

ubuntu@:~/ollama$ sudo apt-get install build-essential
[output snipped]

ubuntu@machine:~/ollama$ CGO_ENABLED go build .
CGO_ENABLED: command not found

ubuntu@machine:~/ollama$ CGO_ENABLED=1 go build .

ubuntu@machine:~/ollama$ ls
Dockerfile  README.md  app  docs      format  go.sum  main.go  parser       scripts  vector
LICENSE     api        cmd  examples  go.mod  llm     ollama   progressbar  server

Built successfully with CGO_ENABLED=1 go build . and now I have the ollama binary. Thanks again!

<!-- gh-comment-id:1679853298 --> @drusepth commented on GitHub (Aug 16, 2023): Hey, thanks so much. I think it was just that I needed `build-essential`; it wouldn't build with just CGO_ENABLED, but built just fine with it after also installing `build-essential` for gcc. Thanks a ton for your help! Including another console log for posterity toward anyone finding this issue in the future. :) ```console ubuntu@machine:~/ollama$ CGO_ENABLED go build . CGO_ENABLED: command not found ubuntu@machine:~/ollama$ CGO_ENABLED=1 go build . # runtime/cgo cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH ubuntu@:~/ollama$ sudo apt-get install build-essential [output snipped] ubuntu@machine:~/ollama$ CGO_ENABLED go build . CGO_ENABLED: command not found ubuntu@machine:~/ollama$ CGO_ENABLED=1 go build . ubuntu@machine:~/ollama$ ls Dockerfile README.md app docs format go.sum main.go parser scripts vector LICENSE api cmd examples go.mod llm ollama progressbar server ``` Built successfully with `CGO_ENABLED=1 go build .` and now I have the `ollama` binary. Thanks again!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25918