[SOLVED] Windows build: Many classes cannot be found

  • Hello,

    I have built Qt with Visual Studio 2013, created a project (Svg module enabled) and tried to work with QSvgWidget but:

    Cannot open include file: 'QSvgWidget': No such file or directory

    So I checked the directory ...\Qt5.4.1\qtbase\include\QtSvg and there is only one file in it: QtSvgDepends
    Nothing else..

    Same for many other modules: QtMultimedia, QtScript, QtScriptTools, QtWebSockets, QtXmlPatterns, ...

    What is wrong here? It helps to manually set include directories for the Visual Studio project, but this can't be a real solution?
    For example, to be able to work with QSvgWidget, I'd have to manually add "...\Qt5.4.1\qtsvg\include\QtSvg" and "...\Qt5.4.1\qtsvg\include".

    Thank you very much!

  • HI and welcome to devnet,

    can you post your .pro file??
    Have you built Qt on yourself?? Are you sure the build was successfully executed?


    qmake -query

    to verify your Qt installation

  • Thanks for your answer.

    I'm not using Qt Creator, so I don't know about .pro files.
    Yes, as I said, I built it myself with Visual Studio and it seemed to be successful (no errors shown, last messages were something with copied translation files).

    This thread is about similar problems:
    Explanation: http://www.qtcentre.org/threads/58268-Where-is-QScriptable-in-Qt5-2-1?p=259840#post259840
    "Solution": http://www.qtcentre.org/threads/58268-Where-is-QScriptable-in-Qt5-2-1?p=262272#post262272

    So is there anything else I can do to get rid of the "not found" errors?

  • How are you managing your project??
    If you're not using qmake I think could be a problem related to Visual Studio settings

  • I'm not sure what you mean but I'm using the "Qt5 Visual Studio Add-in 1.2.4".

    I had no problems so far, not even with bigger projects. But that's because I always skipped nearly every module because I didn't need it.
    But now I wanted to try a few things and did a rebuild with many modules enabled, but cannot use them properly now..

  • Can you check if in your application folder there's a .pro file??

  • Moderators

    @mcosta There's no .pro files and qmake is not used when using Visual Studio.

    @qtacc32 First thing to do is to confirm that the used modules are enabled in the add-in. Right clik on the project -> Qt Project Settings -> Qt Modules Tab. If they are not then (obviously) enable them. If they are grayed out it means that your manual build of Qt failed to build the desired modules.
    Also, can you post the configure params you used to build Qt?

  • Yep, the modules are enabled in the project settings (in this case, "Svg" is enabled but QtSvgWidget is not found).
    Also, as I mentioned already, ...\Qt5.4.1\qtbase\include\QtSvg contains only one file, "QtSvgDepends".

    And these are the configure params I used:

    configure -opensource -confirm-license -debug-and-release -force-debug-info -platform win32-msvc2013 -target xp -mp -ltcg -nomake examples -nomake tests -no-compile-examples -icu -openssl -no-sql-sqlite -no-opengl -no-angle -no-wmf-backend -no-qml-debug -no-native-gestures -no-inotify -no-iconv -no-mtdev -no-nis -no-cups -no-evdev -no-dbus -skip qtactiveqt -skip qtandroidextras -skip qtconnectivity -skip qtdeclarative -skip qtdoc -skip qtenginio -skip qtlocation -skip qtmacextras -skip qtquick1 -skip qtquickcontrols -skip qtsensors -skip qtserialport -skip qtwayland -skip qtwebchannel -skip qtwebkit -skip qtwebkit-examples -skip qtx11extras -I D:\Programming\Libraries\openssl1.0.2a\include

    I have corrected my first post, QSslSocket works (after enabling Network module).
    But I see in many folders in ...\Qt5.4.1\qtbase\include\ with only one file, Qt*Depends.

  • Moderators

    Um, then it sounds like you didn't download the source for qtsvg before compiling Qt. How did you obtain the source?
    I usually use the online installer and select "Source components" when building Qt manually. There's a checkbox for each add-on module, including qtsvg.
    If you cloned the repo using git then if I remember correctly you need to get the add-ons separately, but I'm not sure. Here's the list of all Qt modules on git: Qt Project Git Repository.

  • Moderators

    Btw. It's unrelated but when building from source it's nice to pass a prefix to the configure and run nmake install after the build, e.g.

    configure -prefix %CD%\..\mybuild\ <all the options>
    nmake install

    This would copy all the necessary files to the prefix directory and structure them the way the precompiled builds are. You can then throw out the build directory with all the temporary files you don't need (like .obj and so forth). This reduces the size of the Qt directory significantly and it's easier to find all the modules. Maybe it's also related to your problem, as the qtsvg directory lives outside qtbase in the sources. Maybe it confuses the add-in?

  • I got the source from here: http://download.qt.io/official_releases/qt/5.4/5.4.1/single/qt-everywhere-opensource-src-5.4.1.zip
    The source is complete, otherwise it wouldn't work by manually adding the include dirs ;-)
    In ...\Qt5.4.1\qtsvg\ there is include\ and src\ with all the files..

    I'd want to build with -prefix and nmake install but I read somewhere that this isn't supported on windows, so I'll dig into that again first.

  • Moderators

    I'd want to build with -prefix and nmake install but I read somewhere that this isn't supported on windows

    Yeah, I've seen that too but it's working ok for at least a couple of latest releases, so I think this might be the case of outdated information (the bigger the internet the more catching up it has to do ;) ).

  • Okay, that seemed to work. The headers are there.
    But two problems occured:

    When I wanted to start a Qt application, I was getting an error that the platform plugin couldn't be loaded. So I tried to add all of these to PATH but it didn't work:
    I had to add an env. variable "QT_QPA_PLATFORM_PLUGIN_PATH=D:\Programming\Libraries\Qt5.4.1\plugins\platforms".
    Why is that?

    The other problem is that assistant/designer/linguist.exe all cannot be started anymore because they crash immediately (module: MSVCR120.dll).

    I have no idea at the moment what's going wrong...

    // EDIT:

    Crash callstack:

    Qt5Core.dll!qBadAlloc() Line 2848
    Qt5Core.dll!QByteArray::QByteArray(const char * data, int size) Line 1372
    Qt5Core.dll!QLibraryPrivate::fromRawMetaData(const char * raw) Line 112
    Qt5Core.dll!findPatternUnloaded(const QString & library, QLibraryPrivate * lib) Line 301
    Qt5Core.dll!QLibraryPrivate::updatePluginState() Line 715
    Qt5Core.dll!QFactoryLoader::update() Line 153
    Qt5Core.dll!QFactoryLoader::QFactoryLoader(const char * iid, const QString & suffix, Qt::CaseSensitivity cs) Line 97
    Qt5Gui.dll!`anonymous namespace'::Q_QGS_directLoader::innerFunction() Line 49
    Qt5Gui.dll!QPlatformIntegrationFactory::create(const QString & platform, const QStringList & paramList, int & argc, char * * argv, const QString & platformPluginPath) Line 70
    Qt5Gui.dll!init_platform(const QString & pluginArgument, const QString & platformPluginPath, const QString & platformThemeName, int & argc, char * * argv) Line 1010


  • Moderators

    First, after you built Qt with the prefix make sure you add it to the VS add-in correctly i.e. the prefix path, not the build path. Also, don't move your Qt build to another directory or rename it. If you did you'll have to patch the paths in Qt binaries using e.g. QtBinPatcher. Don't forget to change your solution and project Qt version too after that (right click on solution and change solution Qt version, right click on project and change Qt version in the Qt settings dialog).

    Second - please, please!, don't pollute PATH or other environment variables. You'll thank me later when you decide to have two Qt versions side by side or have Qt app installed that uses some other version. The suggested method of deployment on Windows is copying Qt libraries to the app directory, as described here. This goes for the core Qt dlls as well as platform and other plugins. For your own sake and future sanity I strongly suggest to follow that path.

    As for the crashing tools I'm not sure. Maybe some other env. variables you set are colliding? You can try to run any of the tools through profile mode in Dependency Walker and see if it crashes on loading any of the libs.

  • Oh, I renamed the directory after nmake install finished (from Qt5.4.1build to Qt5.4.1). That could be the problem. I'm rebuilding now from scratch.
    But why are the binaries dependent on paths?!

    I am adding to PATH because it's the development machine :-P
    Otherwise I would have to copy the binaries to every single application directory I'm developing, right?

  • Moderators

    I'm rebuilding now from scratch.

    No need to do that. Using the QtBinPatcher is a one-click solution to moving Qt.

    But why are the binaries dependent on paths?!

    It's a long story. In short qmake tracks which libraries were used to build Qt so that it can link to the right versions when you link your app using Qt. When you install Qt from an installer it does the patching for you but if you decide to build Qt yourself and then move it to another directory you need to patch it to fix the paths (which are embedded in qmake exec and in the .prl files in the lib directory among other places). The simplest is to build it with the desired directory set in prefix. This way you don't need any patching.
    But don't worry. This is only development side. End users don't need any of this.

    I am adding to PATH because it's the development machine :-P

    This is not an excuse. That's even worse if you ask me.

    Otherwise I would have to copy the binaries to every single application directory I'm developing, right?

    Right, but not everything. Just the dlls the app actually uses. You will need to do this anyway when deploying so I don't see a problem. Anyway, I'm guessing you're not developing a 100 apps at a time right?

  • Everything seems to work now.

    I don't plan to have more than one version for development and any program I installed so far deployed its own binaries, so they would be loaded before looking into PATH, or what issues do you mean?

  • Moderators

    I don't plan to have more than one version

    This is a line from a bad Seagal movie I love to quote in this kind of situations :)

  • Hahah, yea, but for now it's just more comfortable, should I run into issues, I'll have it in mind.
    I have kinda good control over my computer :-P

    Thanks to everyone.

  • This post is deleted!