Personal tools
You are here: Home Developer Resources Knowledgebase When using Qt with STL it crashes with a memory access exception, how do I fix this?
Document Actions

When using Qt with STL it crashes with a memory access exception, how do I fix this?



Answer:

If this happens, then the problem is usually either one of two things:

  • A mismatch of runtime libraries - If you have built Qt in release mode and your application in debug mode this means that it will be using two different runtime libraries. A release C runtime for Qt and a debug C runtime for your application. This means that there are two heaps in use and as a result if objects get passed from one heap to another (i.e. from Qt to the application and vice versa) then memory corruption will occur. You can usually catch this at build time, if you see a link warning about default libraries then this is usually indicitive of this problem. The only way to resolve it is to ensure that Qt and your application is built in the same mode. With Qt 4, by default both versions are available so you should not encounter this problem.
  • The environment variables are not set correctly - If you have more than one compiler installed on your machine, then it is possible that the environment variables (particularly INCLUDE and LIB) are not pointing to the right compiler. You should ensure that the environment variables match the compiler that you are actually using to build and run the application.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: