I have found the answer in here. But a new problem is raised.
I put a breakpoint on the line QgsApplication app(argc, argv, true) and the debugger pops up this:
And at the end of the program, when the line return app.exec(); run, this warning is displayed on the console.
QApplication::exec: Please instantiate the QApplication object first
PS: I explain the problem completely here.