App deployment error



  • I want to deploy my C++ app with QT GUI library. When I run it from IDE it runs fine, but when I run it as .exe with all necessary .dll, I get error:

    The procedure entry point __cxa_throw_bad_array_new_length could not be located in the dynamic link library ...\Qt5Core.dll.
    

    I have checked, and in both cases, I use MinGW as compiler. I have also tried to use windeployqt.exe, but same error occurs.


  • Qt Champions 2016

    @Djolas2001
    Have you deployed the MinGW specific dlls along? This should be exported from the MinGW libs.



  • @kshegunov Yes, I have copied all necessary dlls from MinGW folder. I have followed instructions on this link.


  • Qt Champions 2016

    @Djolas2001
    Could you provide a list of files you've deployed and information on which version of Qt and MinGW were used? Could you also check with dependency walker on what MinGW libs (and versions) the said QtCore5.dll depends?



  • @kshegunov Here are screenshots. Is that enough?


  • Qt Champions 2016

    @Djolas2001
    Yes. It looks mostly okay to me, but the thing that's bothering me is the errors/warnings you're getting in the dependency walker. Especially the redness of the stdc++ under Qt5Core.dll. The only thing that comes to mind is some sort of compiler version mismatch, but it's a long-shot ...

    PS:
    Wait a second, why is your application x86 but is linking against the x64 windows binaries ... this doesn't look right.



  • @kshegunov Is there any solution? I yesterday tried to update both MinGW and Qt, but both have latest versions.


  • Qt Champions 2016

    @Djolas2001
    See my edited answer. I believe you have mismatch in architectures for one, and that you should try tracking the missing dependent symbol in Qt5Core.dll.



  • @kshegunov Excuse me, I am new in programming, so can you explain me how to try tracking the missing dependent symbol?


  • Qt Champions 2016

    @Djolas2001

    how to try tracking the missing dependent symbol?

    I meant finding which dll exports it and what might be the problem with said dll.
    I had checked and the dll that exports that particular symbol is libstdc++-6.dll So you should search for the problem there.

    I am new in programming

    Okay, then. Take a quick glance here so you have at least a basic understanding of the matter. Now to the core:
    The .exe has a list of dll files to load, and each of them have a list of their own. So when you start your program there's a special application (in the OS) called the loader that starts transferring the needed dlls to memory, and finally when that's done it does the same for your executable. Only when it's finished your program can actually run.

    Your (original) problem is that Qt5Core.dll (used in your application) uses an external function (from another .dll) but that function (or symbol) can't be found by the loader. Those dlls are called dependencies, because Qt5Core.dll can't be loaded before any other .dll it references. What you see with the dependency walker is the dependency tree - the modules (in windows terms) that have to be loaded before your application; and when you expand each of them you see the exported symbols.

    At the end of the day, leaving technicalities aside, every single dll must be loaded, and every single symbol found in those loaded dlls for your application to run. Since, the loader can't locate the __cxa_throw_bad_array_new_length symbol your application fails to run. A hint, is that it runs fine inside your IDE, so that means that in all probability you had deployed a wrong dll, or rather wrong combination of dlls. What I suspect happened is that you'd built your application and had shipped dlls from MinGW that are different from those used when Qt was built. Or you have copied 32bit dlls, when 64bit ones are expected.

    Probably the cleanest attempt would be to create a new empty folder and carefully copy each of the dlls. Also, make sure that compiler versions match between all the dlls and the application. And don't copy the system dlls - kernel32, msvcrt, shell32 etc. at least until you're convinced your application is working fine without them (you can copy those at the end of the deployment if it's really required, although I don't believe it is).

    I know it's not exactly what you were expecting, but it's the best I can do without actually doing it myself.



  • @kshegunov I have tried everything, but error repeats. I have re-installed MinGW and Qt both completely with right versions, put all correct dll. And nothing helps.


  • Lifetime Qt Champion

    Hi,

    Did you use windeployqt to deploy your application ?



  • Hi, do you still get the same error "... ____cxa_throw_bad_array_new_length ..."?

    I think perhaps you are copying the wrong Qt5Core.dll to your directory (where your image viewer.exe program is), you're sure you are copying Qt5Core.dll from C:\Qt\5.6\mingw492_32\bin and not from C:\Qt\Tools\QtCreator\bin?


  • Qt Champions 2016

    @Djolas2001
    I don't know what to suggest ... See @hskoglund's note and if nothing else works, walk us through the whole process - what dll you copied from what folder to which directory.



  • I get same error. Folder link with dlls and error link. Also I have completely re-installed Qt, and now I have only MinGW as compiler so I can't miss.



  • Hi, how big (in bytes) is your Qt5Core.dll in your folder in D:
    Also what date and time does it have?



  • Here are all information about Qt5Core.dll. Also I have created short video, about how I move files.



  • Hi, very good idea with making a movie, now I think what your problem is, I mean how to solve it:

    first, your Qt5Core.dll is indeed correct, the problem was Windows 10 saying (incorrectly) that the "..the procedure entry point __cxa_throw_bad...... could not be located in Qt5Core.dll"

    Actually Qt5Core.dll imports this function from another dll called libstdc++-6.dll
    This file is a part of the MinGW toolchain, but on your Windows PC you got multiple versions of this file, and the one in your path is older than the one in Qt 5.6.

    So try also copying the libstdc++-6.dll from C:\Qt\5.6\mingw49_32\bin directory to your folder D: and then try to start your app again.



  • @hskoglund Thank you very much, now it works. :)



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.