c++profilerpprofgperftoolsgperf

gperftools not installing -lprofiler on Mac after installing it with brew


Recently I wanted to profile my cpp code and came across gperftool, but there aren't really clear instructions on how to use it with Mac. So far I have run brew install gperftools and wanted to compile my simple cpp file which just outputs "Hello world!". I run g++ main.cpp -lprofiler -o main but get error ld: library not found for -lprofiler. I really appreciate it if you could guide me or should me a tutorial where it's easy to follow. Thanks :)

Edit: Currently I am using MacOS with new M1 chip (not sure if that can cause any issue)


Solution

  • So brew didn't install the binaries and that's it.

    Follow these steps if you are having a hard time making it work

    1. clone https://github.com/gperftools/gperftools
    2. run ./autogen.sh
    3. run ./configure
    4. make && sudo make install
    5. you should see some path where the binaries where installed, if you wanna take a look at it to make sure (mine was /usr/local/lib)
    6. Profit