How to check the flow of execution(programs , functions invocations)

Yes you need to rebuild. For example if you built previously by ninja image-classifier, and then you make changes to a .cpp or .h file, then you need to rerun ninja image-classifier before your command. This is how compiled languages like C++ work.