0

I installed the jemalloc library on my ubuntu machine by

sudo apt-get install libjemalloc-dev

Now, I can't compile a simple code that uses the jemalloc library:

#include <jemalloc/jemalloc.h>
#include <iostream>

int main() {
    void* ptr = je_malloc(16);
    return 0;
}

I compile it by g++ -ljemalloc example.cpp.

The error I get is

example.cpp: In function ‘int main()’:
example.cpp:5:24: error: ‘ je_malloc’ was not declared in this scope
  void* ptr = je_malloc(16);

I even tried installing jemalloc using its source file and changed my header to "jemalloc/jemalloc.h" (instead of <..>), and linked to it using g++ -L./jemalloc/lib example.cpp, but it didn't help.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182

2 Answers2

0

When I look at the documentation there is no function je_malloc, so the error is normal

Replace je_malloc by malloc

bruno
  • 32,421
  • 7
  • 25
  • 37
0

I know it is too late but it may be useful for someone else. If you want to use the je_ prefixed version of the API you have to add --with-jemalloc-prefix=je_ option when compiling the library (in this case when running configure script).

tarekasis
  • 68
  • 7