PDA

View Full Version : [SOLVED]mainwindow.obj:-1: error: LNK2019: unresolved external symbol



bshikari
11th February 2013, 18:03
I try to compile my program and I get the following errors:


mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall FullGraph::FullGraph(class QWidget *)" (??0FullGraph@@QAE@PAVQWidget@@@Z) referenced in function "private: void __thiscall MainWindow::on_actionExample_triggered(void)" (?on_actionExample_triggered@MainWindow@@AAEXXZ)

mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall FullGraph::setID(int)" (?setID@FullGraph@@QAEXH@Z) referenced in function "private: void __thiscall MainWindow::on_go_button_clicked(void)" (?on_go_button_clicked@MainWindow@@AAEXXZ)

debug\GraphIt.exe:-1: error: LNK1120: 2 unresolved externals

This is my code:

mainwindow.h


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtGui>
#include <QtCore>
#include <QFileDialog>

#include "fullgraph.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

public slots:

private:
Ui::MainWindow *ui;
FullGraph *new_graph;

private slots:
void on_actionAbout_triggered();
void on_actionQuit_Alt_F4_triggered();
void on_actionExample_triggered();
void on_pushButton_clicked();
void on_go_button_clicked();
};

#endif // MAINWINDOW_H



mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "about.h"
#include "fullgraph.h"


#include <stdio.h>
#include <string.h>



MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_actionAbout_triggered(){
About new_about;

new_about.setModal(true);
new_about.exec();
}

void MainWindow::on_actionQuit_Alt_F4_triggered(){
close();
}


void MainWindow::on_actionExample_triggered()
{

new_graph = new FullGraph(this);
new_graph->show();

}

void MainWindow::on_pushButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
"",
tr("Files (*.*)"));

ui->fp_input->setText(fileName);
}


void MainWindow::on_go_button_clicked()
{
QString _input = ui->fp_input->text();
QFile file_in(_input);

//INI LABEL TEXT
ui->error->setText(" ");

//CHECK FILE EXISTANCE
if(!file_in.open(QIODevice::ReadOnly | QIODevice::Text)){
ui->error->setText("File doesn't exist");
return;
}
QTextStream text(&file_in);


file_in.close();

new_graph = new FullGraph(this);
int _id = ui->id_input->text().toInt();
new_graph->setID(_id);
new_graph->show();
}



fullgraph.h

#ifndef FULLGRAPH_H
#define FULLGRAPH_H

#include <QDialog>
#include <QtGui>
#include <QtCore>

namespace Ui {
class FullGraph;
}

class FullGraph : public QDialog
{
Q_OBJECT

public:
explicit FullGraph(QWidget *parent = 0);
~FullGraph();
void setID(int _ID);

private slots:
void on_browse_fpout_clicked();
void on_saveit_clicked();

private:
Ui::FullGraph *ui;
int ID;
QGraphicsScene *scene;

};

#endif // FULLGRAPH_H



fullgraph.cpp

#include "fullgraph.h"
#include "ui_fullgraph.h"

FullGraph::FullGraph(QWidget *parent) :
QDialog(parent),
ui(new Ui::FullGraph)
{
ui->setupUi(this);
ID = 0;

//create graphicsview
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);

//set cross background
QBrush brush(Qt::gray, Qt::CrossPattern);
scene->setBackgroundBrush(brush);

}

FullGraph::~FullGraph()
{
delete ui;
}

void FullGraph::setID(int _ID)
{

ID = _ID;

}

void FullGraph::on_browse_fpout_clicked()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
"",
tr("Portable Network Graphics (*.png)"));
ui->filename_out->setText(fileName);
}

void FullGraph::on_saveit_clicked()
{
QString fileName = ui->filename_out->text();

QImage *image = new QImage(382, 238, QImage::Format_ARGB32_Premultiplied);
QPainter *p = new QPainter(image);
p->setRenderHint(QPainter::Antialiasing);
scene->render(p);
p->end();

// Save it..
image->save(fileName, "PNG");
}



I do realise the code is highly incomplete, as it does barely nothing at all. I just wanted to check if all this is right before I started codding the rest.
I've checked a lot of forums and threads about this but nothing helped, so I started this one.

Thank you in advance

ChrisW67
11th February 2013, 22:03
The linker is reporting that it cannot find an implementation of the those functions. Is fullgraph.cpp listed in SOURCES? Does fullgraph.lib appear in the linker command that was executed to produce the error? Does the error persist if you do a clean rebuild?

bshikari
11th February 2013, 22:28
The linker is reporting that it cannot find an implementation of the those functions. Is fullgraph.cpp listed in SOURCES? Does fullgraph.lib appear in the linker command that was executed to produce the error? Does the error persist if you do a clean rebuild?

I deleted the previously created files and it compiled successfully. Thanks