peterpann
Goto Top

Main.obj:-1: Fehler: LNK2019: Verweis auf nicht aufgelöstes externes Symbol

Hallo,

ich wollte in c++ eine eigene Klasse anlegen, aber der gute Linker scheint etwas dagegen zu haben... Leider finde ich nicht wie ich das beheben kann...
Ich verwende den QT-Creator. Meine Klasse heißt "test" anbei die Quellcodes... Wenn ich die Klasse in die main schreibe funktioniert es...
Der genaue Fehlercode:
main.obj:-1: Fehler: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl test::test(void)" (??0test@@QEAA@XZ)" in Funktion "main".
debug\Aufg2_vonvorne.exe:-1: Fehler: LNK1120: 1 nicht aufgelöste Externe

.pro
#-------------------------------------------------
#
# Project created by QtCreator 2016-11-17T15:55:04
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Aufg2_vonvorne
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
        readdatei.cpp \
    test.cpp

HEADERS  += mainwindow.h \
         readdatei.h \
    test.h

FORMS    += mainwindow.ui

test.h
#ifndef TEST_H
#define TEST_H


class test
{
public:
    test();
    int x;
};


#endif {{comment_single_line_double_slash:0}}

test.cpp
#include "test.h" 
#include <stdio.h>

test::test()
{

int x = 1;

}

main.cpp
#include "mainwindow.h" 
#include <QApplication>
#include <stdio.h>
#include "readdatei.h" 
#include <iostream>
#include "test.h" 

using namespace std;

//class test{
//public:
//    int x = 1;
//};

int main(int argc, char *argv)
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    test ctest;
   // int itest = 1;
    //double testat = ctest.x;

    cout  <<endl;

    return a.exec();
}

Danke im Vorraus! face-smile

Content-Key: 321309

Url: https://administrator.de/contentid/321309

Printed on: April 23, 2024 at 16:04 o'clock