g++jemalloc

Jemalloc functions not declared in this scope


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.


Solution

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

    Replace je_malloc by malloc