2

I have made some changes and I am trying to compile google-perf(TCMalloc) on Mac OS X Yosemite 10.10.3, I followed step return here Install gperf. But, I am getting below linking error.

./autogen.sh basically autoreconf -i -> successful no error

./configure -> successful no error

make -> below error

libtool: link: g++ -D_THREAD_SAFE -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-cfree -fno-builtin-memalign -fno-builtin-posix_memalign -fno-builtin-valloc -fno-builtin-pvalloc -Wno-unused-result -fno-builtin -g -O2 -D_THREAD_SAFE -o .libs/tcmalloc_minimal_unittest src/tests/tcmalloc_minimal_unittest-tcmalloc_unittest.o src/tests/tcmalloc_minimal_unittest-testutil.o -Wl,-bind_at_load  ./.libs/libtcmalloc_minimal.dylib ./.libs/liblogging.a
Undefined symbols for architecture x86_64:
  "_memalign", referenced from:
      testing::RunAllTests(int, char**) in tcmalloc_minimal_unittest-tcmalloc_unittest.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I installed gcc but didn't help.

Can any one help me to resolve this issue?

eswaat
  • 733
  • 1
  • 13
  • 31

2 Answers2

0

I'm not OSX expert. I do have some access to older OSX version where I test things from time to time. But I do know a bit of gperftools as one of maintainers of this code. So let me try to help you with some ideas.

  1. Please make sure that everything compiles without your changes. I.e. lets exclude your changes as potential source of your issue.

  2. See if source release (.tar.gz) compiles. I.e. it already includes configure which bundles autoconf & automake & libtool that is known to work. So just download .tar.gz release into separate place, unpack, ./configure && make (so without ./autogen.sh step) and see if it works.

It is possible that issue you're experiencing is something specific to newer version of OSX (I think yosemite is latest but not sure since apple stuff is not my cup of tea). One way to avoid this possibility is testing your change under GNU/Linux virtual machine (while continuing to investigate why things don't work on OSX ).

  • Problem persist without my changes. I tried your 2nd step and got same error. Same change is working fine in my linux machine. – eswaat Sep 24 '15 at 18:45
  • Given that we don't have _memalign anywhere in our code, I suspect something in OSX standard includes is #define-ing something (like posix_memalign to be _memalign). But lacking access to OSX box I cannot confirm that. – Aliaksei Kandratsenka Sep 26 '15 at 02:09
0

The problem is that something went wrong with the configuration. Mac OS X does not support memalign, which is why the build is failing (see OSX lacks memalign).

Here are two easy options that should almost certainly work:

  1. Download a release tarball rather than building from the source. This way, you should avoid any issues with autoconf and friends not doing what you hoped they would do.
  2. Install it using Homebrew. Homebrew is a Mac package manager that should be your go-to for most of your Unix software needs: it just works, unlike building packages from source. If you've used apt-get or something similar, it will feel quite familiar. There are "formulas"(packages) for tons of things, including tcmalloc; install MacBrew, then do this:

    sudo brew install google-perftools

I am using a slightly newer version of Yosemite, and I just verified that this works.

EmeryBerger
  • 3,897
  • 18
  • 29