[Qt-interest] undefined reference to... collect2: ld returned 1 exit status

Nikos Chantziaras realnc at arcor.de
Sat Mar 27 16:53:41 CET 2010


On 03/27/2010 04:54 PM, M. Bashir Al-Noimi wrote:
> I've created Two classes (as mentioned below) one of them needs QList so
> I added #include<QObject>

When you need a QList, then #include <QList>, not <QObject>.


>  but when I tried to create new object from
> these classes I got the following error:
>
>               YSimulate *sim =new  YSimulate(12, 5, 3);
>
> obj/mainwindow.o:Q:\Academic\F09\project1\FactorySimulator/mainwindow.cpp:128:
> undefined reference to `YSimulate::YSimulate(int, int, int)'

You probably didn't define the (int,int,int) constructor or did not 
include the file where it's defined in the build.  There's no way to 
tell since your zip attached got stripped:

   "This email contained a .zip file attachment. Raytheon does
    not allow email attachments that are considered likely to
    contain malicious code. For your protection this attachment
    has been removed."


 > #if  !defined(_YMACHINE_H)
 > #define  _YMACHINE_H

Using identifiers and macros that start with an underscore ("_") is 
usually not a good idea, only the compiler and its include files should 
use them.  This has probably nothing to do with the error you're getting 
though; I'm just pointing it out.



More information about the Qt-interest-old mailing list