"Undefined reference to `mcount'" when trying to use -pg [Termux]
<p>I've completed the first part of my project, and I want to know how well / bad it performs by profiling it with <code>gprof</code>. I am working on Android using a Linux emulator named Termux, and I am using g++ as the compiler.</p>

<p>Everything compiles without errors and even warnings, and the binary runs perfectly.</p>

<p>So I decided to put the <code>-pg</code> flag among the other flags in my makefile, (meaning that both compilation and linking is performed with <code>-pg</code>) and tried recompiling everything. But something seems to not work properly: during compilation, everything is normal. But when linking I get a <code>argument unused during compilation: '-pg'</code> warning and then a lot of <code>undefined reference to 'mcount'</code> (it doesn't even display all of them, after a bit it says <code>more undefined references to 'mcount' follows</code>) errors, and at the end a <code>linker command failed with exit code 1</code> error.</p>

<p>What is causing this behaviour? Is something broken / missing on the platform I am using? Can I fix that? How?</p>