1

I have a project in Qt Creator and am trying to compile a static release. To do so, I have added "static" to my "CONFIG" option in my .pro file.

After rebuilding all the files, I get a folder named "release" with an executable and a few other files inside of it. When trying to execute the generated file, I get an error that reads as such:

"The procedure entry point __cxa_throw_bad_array_new_length could not be located in the dynamic link library C:\Qt\5.5\mingw492_32\bin\QtCore.dll"

This error message remains whether I use mingw 5.5.0 or 5.4.2 to compile the files.

Using dependency walker and coping the "correct" QT dll files also does not resolve the problem.

What I know already: This error happens to people who copy the wrong QTCore.dll to their project folder. However, since I am not copying any .dll files, I don't know how to use this information to my advantage.

In conclusion, my question is: How do I stop this error from occurring? Moreover, is there a better way to statically compile a qt application?

user2503170
  • 145
  • 1
  • 8

1 Answers1

2

To build static release of your application you basically need two things:

1) add

CONFIG += static

in your .pro file (you did it) and don't copy any Qt dlls.

2) you need to build static Qt

https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW

By default Qt is installed prepared for dynamic linking, this is why you need to build static Qt on your own.

You may want to look also at this great Q&A:

Qt static linking and deployment

but it deals mainly with Qt4. Idea is the same.

After you will build static Qt you will need to rebuild your application. And don't copy any Qt dlls.

Community
  • 1
  • 1
demonplus
  • 5,613
  • 12
  • 49
  • 68