Linking with libtcmalloc ubuntu
You can't link simply to a file with -l
if it doesn't end exactly with .so
, since the linker assumes a particular naming convention (lib*.so
).
You have several choices:
Install
libtcmalloc-minimal0-dev
if it exists, which should provide the.so
dynamic link.Create the symlink yourself:
cd /usr/lib; ln -s libtcmalloc_minimal.so.0.0.0 libtcmalloc_minimal.so; cd -
Link directly to the library without the symlink by using
gcc test.c /usr/lib/libtcmalloc_minimal.so.0.0.0
Link using the
-l
option using the full name:-l:libtcmalloc_minimal.so.0.0.0
Vivek Goel
Updated on June 09, 2022Comments
-
Vivek Goel about 2 years
I had installed the package libtcmalloc-minimal0
but when I try to compile my program with flag
-ltcmalloc-minimal0
I am getting error
/usr/bin/ld: cannot find -ltcmalloc_minimal0
I had checked /usr/lib and the library is there
More Info
dpkg gives following o/p
dpkg -L libtcmalloc-minimal0 /. /usr /usr/lib /usr/lib/libtcmalloc_minimal.so.0.0.0 /usr/lib/libtcmalloc_minimal_debug.so.0.0.0 /usr/share /usr/share/doc /usr/share/doc/libtcmalloc-minimal0 /usr/share/doc/libtcmalloc-minimal0/TODO /usr/share/doc/libtcmalloc-minimal0/AUTHORS /usr/share/doc/libtcmalloc-minimal0/copyright /usr/share/doc/libtcmalloc-minimal0/changelog.gz /usr/share/doc/libtcmalloc-minimal0/README.gz /usr/share/doc/libtcmalloc-minimal0/changelog.Debian.gz /usr/lib/libtcmalloc_minimal.so.0 /usr/lib/libtcmalloc_minimal_debug.so.0
and I am compiling for 64 bit mode
and library is also 64 bit
file /usr/lib/libtcmalloc_minimal.so.0.0.0 /usr/lib/libtcmalloc_minimal.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped
-
Vivek Goel over 12 yearssame error with ltcmalloc_minimal see the edit to see dpkg o/p
-
Basile Starynkevitch over 12 yearsperhaps you need to run
ldconfig
. To understand whatgcc
is doing, pass it the-v
flag. -
Naveen about 7 yearsSo what part of the code would require libtcmalloc-minimal? Does new/delete statements require it?