Tcmalloc is an open source memory management library of Google. As a substitute of glibc malloc, the efficiency of tcmalloc is several times that of gclibc malloc. It’s very easy to use tcmalloc in the project. We use the static compilation method. By adding the link option – ltcmalloc, we can statically link libtcmalloc. A. However, an unexpected situation occurred during the link process, and the following error was reported:
../3party/static_libs/libtcmalloc.a(libtcmalloc_la-linuxthreads.o): In function `TCMalloc_ListAllProcessThreads':
linuxthreads.cc:(.text+0x333): undefined reference to `sem_init'
linuxthreads.cc:(.text+0x41c): undefined reference to `sem_post'
linuxthreads.cc:(.text+0x477): undefined reference to `sem_destroy'
../3party/static_libs/libtcmalloc.a(libtcmalloc_la-linuxthreads.o): In function `ListerThread':
linuxthreads.cc:(.text+0x67b): undefined reference to `sem_wait'
collect2: error: ld returned 1 exit status
sem_ Init is the library function, and the header file is # include & lt; semaphore.h>。 After searching a lot of materials, it is said that the link option lpthread is missing, but our makefile has the lpthread option, and we tried to add ptthread in the compilation option, but it still has no effect. After trying all kinds of methods, we finally tried to put the lpthread option behind the tcalloc option, and we passed it. It’s quite a Wulong
Similar Posts:
- Undefined reference to ‘pthread’ appears in Linux Ubuntu running thread program_ Create ‘and undefined reference to’ pthread ‘_ ‘join’ error.
- Hi3516DV300 Chip Error: “undefined reference to ×”
- The source code installs the git tool, which shows /usr/local/lib64/libcrypto.a(dso_dlfcn.o) undefined reference to `dlopen’
- undefined symbol: xxx – undefined reference to `typeinfo
- Using SQLite to show undefined reference to ` SQLite3_ open’…
- [Solved] LD: library not found for – XXX when Xcode compiles code
- [Solved] undefined reference to `cv::imread(std::string const&, int)’
- error adding symbols: DSO missing from command line
- [Solved] Undefined reference_G++ _GLIBCXX_USE_CXX11_ ABI compilation error: STD:: Basic_String and STD::__cxx11::basic_String cannot match