Solved QCoreApplication console application does not output with Valgrind
-
I have a QCoreApplication console application which works fine if I run it normally, but when I run it with "Analyze -> Valgrind Memory Analyzer", there is no output after "hi":
Runner::Runner(QCoreApplication *parent) { app = parent; } void Runner::run() { cout << "hi" << endl; QCommandLineParser parser; parser.setApplicationDescription("Description..."); parser.addHelpOption(); cout << "does not output here" << endl; app->quit(); } int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); Runner *runner = new Runner(&app); QTimer::singleShot(0, runner, SLOT(run())); return app.exec(); }
-
@Guerrian QCommandLineParser should be place in main()!
int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QCommandLineParser parser; parser.setApplicationDescription("Description..."); parser.addHelpOption(); parser.process(app); Runner *runner = new Runner(&app); QTimer::singleShot(0, runner, SLOT(run())); return app.exec(); }
-
@KroMignon Still doesn't work with Valgrind... no output.
-
Both testcases work fine for me on the command line, with or without valgrind.
-
@Christian-Ehrlicher I tried running on the command line and I got the message:
error while loading shared libraries: libMyLib.so.0: cannot open shared object file: No such file or directory
So then I created a bash script just called "myscript":
#!bin/bash LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/daniel/Documents/MYLIB/lib export LD_LIBRARY_PATH exec "./MyApp"
And made it executable:
chmod +x myscript
But when I run it says:
bash: ./myscript: bin/bash: bad interpreter: No such file or directory
-
I'm pretty sure you don't have bin/bash in your current work dir...
-
@Christian-Ehrlicher I forgot the slash, it should be:
#!/bin/bash
-
@Guerrian said in QCoreApplication console application does not output with Valgrind:
I forgot the slash
correct :)