Qt World Summit: Submit your Presentation

Linker Errors always after instantiation

  • Hey all,

    I'm getting very frustrated with QT and I would like some advice on this. Every time I instantiate a new class within QT I will get linker errors without fail even I it is correctly instantiated. Now if I close the project and copy and paste everything into a fresh project, the linker error is gone and it works as it should. I have to copy and paste everything into a new project every time I want to do this. Any thoughts on how to fix this?


  • To be more specific the error is a LNK2019

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You don't give enough information: what exact class are you using that gets you this error ? Did you check what module it's in ? Did you add the module to your pro file ?

    e.g. using QSqlDatabase requires the sql module so your have to add QT += sql to your pro file and re-run qmake before you can use them

  • @SGaist

    For example:

    class A{
    //constructor and functions here

    class B{
    // a.h included here
    A *name = new A();


    every time that format will throw a linker error. Say both of those are my own custom classes.

  • Lifetime Qt Champion

    Do I read right that you are including a header inside a class definition ?

Log in to reply