[SOLVED]mainwindow.obj:-1: error: LNK2019: unresolved external symbol
I try to compile my program and I get the following errors:
Code:
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
Code:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtGui>
#include <QtCore>
#include <QFileDialog>
#include "fullgraph.h"
namespace Ui {
class MainWindow;
}
{
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
Code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "about.h"
#include "fullgraph.h"
#include <stdio.h>
#include <string.h>
MainWindow
::MainWindow(QWidget *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()
{
"",
tr("Files (*.*)"));
ui->fp_input->setText(fileName);
}
void MainWindow::on_go_button_clicked()
{
QString _input
= ui
->fp_input
->text
();
//INI LABEL TEXT
ui->error->setText(" ");
//CHECK FILE EXISTANCE
ui->error->setText("File doesn't exist");
return;
}
file_in.close();
new_graph = new FullGraph(this);
int _id = ui->id_input->text().toInt();
new_graph->setID(_id);
new_graph->show();
}
fullgraph.h
Code:
#ifndef FULLGRAPH_H
#define FULLGRAPH_H
#include <QDialog>
#include <QtGui>
#include <QtCore>
namespace Ui {
class FullGraph;
}
{
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;
};
#endif // FULLGRAPH_H
fullgraph.cpp
Code:
#include "fullgraph.h"
#include "ui_fullgraph.h"
FullGraph
::FullGraph(QWidget *parent
) : ui(new Ui::FullGraph)
{
ui->setupUi(this);
ID = 0;
//create graphicsview
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()
{
"",
tr("Portable Network Graphics (*.png)"));
ui->filename_out->setText(fileName);
}
void FullGraph::on_saveit_clicked()
{
QString fileName
= ui
->filename_out
->text
();
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
Re: mainwindow.obj:-1: error: LNK2019: unresolved external symbol
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?
Re: mainwindow.obj:-1: error: LNK2019: unresolved external symbol
Quote:
Originally Posted by
ChrisW67
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