2

I've completed the first part of my project, and I want to know how well / bad it performs by profiling it with gprof. I am working on Android using a Linux emulator named Termux, and I am using g++ as the compiler.

Everything compiles without errors and even warnings, and the binary runs perfectly.

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

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

user6245072
  • 2,051
  • 21
  • 34

1 Answers1

3

Sorry for the short answer, but I'm on mobile. Making a community wiki.

In Termux, g++ is a symlink to clang. -pg is a gnu feature, so does not function when linking using clang.

You could use clang-appropriate techniques for profiling, or install a real g++. One reference is https://android.stackexchange.com/questions/182130/use-gcc-compiler-in-termux but there is also "google performance tools" for profiling out there somewhere.

fuzzyTew
  • 3,511
  • 29
  • 24