Qt プログラムが突然終了する

プログラムを実行すると画面も表示されずに終了する。

Starting path\to\helloworld.exe...
プログラムが突然終了しました。
path\to\helloworld.exe crashed.
/path/to/helloworld を起動中...
プログラムが突然終了しました。
/path/to/helloworld がクラッシュしました

デバッグ実行すると次のメッセージが表示される。

During startup program exited with code 0xc0000139

f:id:renkin3q:20170908170346j:plain

原因1

C:\Windows\SysWOW64 に、他の libstdc++-6.dll がインストールされていたため。

解決方法1

ビルドに使った libstdc++-6.dll を実行ファイルと同じフォルダーにコピーする。

原因2

QApplication の派生クラスのコンストラクタの第1引数を “int argc” にしていたため。

解決方法2

“int &argc” に修正する。(QApplication の第1引数は “int &argc")