Menu

Can't start cppcheckgui: Qt platform plugin could not be initialized

2019-03-19
2019-03-27
  • Florian George

    Florian George - 2019-03-19

    Somewhere around Version 1.85, starting the CppCheck GUI would result in the following error message:

    The application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    Available platform plugins are: direct2d, minimal, offscreen, webgl, windows, windows.

    The reason for this appears to be that I have a custom self compiled version of Qt, and my QT_PLUGIN_PATH environment variable is pointing to its "qt\plugins" directory. This seems to cause CppCheck to ignore its own "platforms" directory and attempt to use my "qt\plugins\platforms" directory, failing to load the platform dll.

    Workaround #1: Rename my "platforms" directory to "platforms.old". Now I can use CppCheck, but I can't develop/run my own qt applications.

    Workaround #2: Create a cppcheck_fixed.cmd with the following two lines:

    SET QT_PLUGIN_PATH=
    "C:\Program Files\CppCheck\cppcheckgui.exe"
    

    This works, I just have an additional console window in the background.

    Possible fix: Before creating the QApplication object in the main.cpp, add the following line:

    QCoreApplication::addLibraryPath(".");
    QApplication app(argc, argv);
    

    This should make the local working directory the first directory to be checked for the "platforms" directory.
    I can't test this myself as if I would build CppCheck, it would use my plugin dlls and have no issue, but this has for me often solved issues like this when deploying applications into other people's development environments.

     
  • versat

    versat - 2019-03-27

    IMHO this fix sounds reasonable and should not break anything.
    "." should already be the default i guess.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.