# Building go application with jemalloc errors out

**URL:** <https://discuss.dgraph.io/t/building-go-application-with-jemalloc-errors-out/17034>\
**Category:** Badger\
**Tags:** badger\
**Created:** [March 17, 2022, 4:01pm UTC](https://discuss.dgraph.io/t/building-go-application-with-jemalloc-errors-out/17034 "2022-03-17T16:01:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vishal\_Jangid](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vishal_jangid/32/9550_2.png) [@Vishal\_Jangid](https://discuss.dgraph.io/u/Vishal_Jangid)\
**Post date:** [March 17, 2022, 4:01pm UTC](https://discuss.dgraph.io/t/building-go-application-with-jemalloc-errors-out/17034/1 "2022-03-17T16:01:56Z")

</div>

### What version of Go are you using (`go version`)?

```
$ go version 1.17
```

### What operating system are you using?

Rhel 7

### What version of Badger are you using?

v3.2103.2

### Does this issue reproduce with the latest master?

yes

### Steps to Reproduce the issue

install jemalloc  
go run -tags=jemalloc main.go

### What Badger options were set?

Default options

### What did you do?

go run -tags=jemalloc main.go

### What did you expect to see?

```auto

```

### What did you see instead?

```auto
# github.com/dgraph-io/ristretto/z
vendor/github.com/dgraph-io/ristretto/z/calloc_jemalloc.go:73:9: could not determine kind of name for C.je_calloc
vendor/github.com/dgraph-io/ristretto/z/calloc_jemalloc.go:103:3: could not determine kind of name for C.je_free
vendor/github.com/dgraph-io/ristretto/z/calloc_jemalloc.go:143:2: could not determine kind of name for C.je_mallctl
vendor/github.com/dgraph-io/ristretto/z/calloc_jemalloc.go:170:2: could not determine kind of name for C.je_malloc_stats_print

```

---

<div class="post-metadata">

**Author:** ![Abdul\_Aziz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abdul_aziz/32/10321_2.png) [@Abdul\_Aziz](https://discuss.dgraph.io/u/Abdul_Aziz)\
**Post date:** [March 2, 2023, 1:36pm UTC](https://discuss.dgraph.io/t/building-go-application-with-jemalloc-errors-out/17034/2 "2023-03-02T13:36:33Z")

</div>

@Dgraph_Admin any update on this?

@Vishal_Jangid did you get the compilation issue fixed?

I am also facing the same issue but on MacOS.

---

<div class="post-metadata">

**Author:** ![Vishal\_Jangid](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vishal_jangid/32/9550_2.png) [@Vishal\_Jangid](https://discuss.dgraph.io/u/Vishal_Jangid)\
**Post date:** [March 2, 2023, 1:52pm UTC](https://discuss.dgraph.io/t/building-go-application-with-jemalloc-errors-out/17034/3 "2023-03-02T13:52:59Z")

</div>

I was unable to resolve the issue on Rhel 7. I haven’t tried it on MacOS.

---

<div class="post-metadata">

**Author:** ![joshua](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joshua/32/9854_2.png) [@joshua](https://discuss.dgraph.io/u/joshua)\
**Post date:** [March 3, 2023, 1:13pm UTC](https://discuss.dgraph.io/t/building-go-application-with-jemalloc-errors-out/17034/4 "2023-03-03T13:13:53Z")

</div>

Hi Abdul, did you use the makefile in badger to install jemalloc? Try running `make badger` and let us know what happens. Badger compiles with jemalloc on my MacOS machine.

@Vishal_Jangid I can’t speak personally for RHEL but I’d suggest the same advice to compile with `make badger` and report back what happens.

---

<div class="post-metadata">

**Author:** ![Abdul\_Aziz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abdul_aziz/32/10321_2.png) [@Abdul\_Aziz](https://discuss.dgraph.io/u/Abdul_Aziz)\
**Post date:** [March 6, 2023, 6:35am UTC](https://discuss.dgraph.io/t/building-go-application-with-jemalloc-errors-out/17034/5 "2023-03-06T06:35:55Z")

</div>

Hi @joshua,

I cloned the `dgraph-io/badger` repository and executed `make badger` command which resulted in same error:

```auto
Compiling Badger binary...
# github.com/dgraph-io/ristretto/z
/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/calloc_jemalloc.go:73:9: could not determine kind of name for C.je_calloc
/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/calloc_jemalloc.go:103:3: could not determine kind of name for C.je_free
/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/calloc_jemalloc.go:143:2: could not determine kind of name for C.je_mallctl
/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/calloc_jemalloc.go:170:2: could not determine kind of name for C.je_malloc_stats_print
make[1]: *** [badger] Error 2
make: *** [badger] Error 2

```

It would be awesome, if you can guide us with the exact steps on how to build DGraph with MacOS and explicitly mention any external dependencies required separately.

Thanks!

---

<div class="post-metadata">

**Author:** ![joshua](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joshua/32/9854_2.png) [@joshua](https://discuss.dgraph.io/u/joshua)\
**Post date:** [March 16, 2023, 4:04am UTC](https://discuss.dgraph.io/t/building-go-application-with-jemalloc-errors-out/17034/6 "2023-03-16T04:04:15Z")

</div>

Hi @Abdul_Aziz ,

Sorry for the delay. That is interesting - usually this error comes the Cgo preamble being misconfigured (e.g. see [here](https://github.com/golang/go/issues/9733)) but it doesn’t look like that is the problem here.

Could you try running `go install github.com/dgraph-io/badger/v4/badger@latest`? This should also install the Badger CLI. Alternatively, if you want to build the CLI locally, you can try running `go build .` from the Badger subdirectory.

To be clear, if your goal is to build Dgraph from source, you don’t have to first build Badger, since this is just a CLI for debugging (Badger is an embedded key-value store). Instructions for building Dgraph are in the Dgraph readme.
