QT build isse "collect2: Id returned 1 exit status"

funcoding
funcoding used Ask the Experts™
on
I am trying to get started with QT GUIs and went through a hello world program. Added QFileDialog and a Quit button. I then wanted to use the filename from QFileDialog as my video file source and display a video. Came across Phonon in QT help to display videos and was trying to add a video player when I started getting the ":: error: collect2: ld returned 1 exit status" error.

I would appreciate if someone can help me understand what I am doing wrong. Also, suggestion based on best practices as to where I should place the Videoplayer declaration/definition would be appreciated.

What I noticed was if I limit the Videoplayer line to just the player declaration, that is:
Phonon::VideoPlayer *player;
I don't get this error. Certainly its something simple and conceptual I am missing...
#include "hello.h"
#include "ui_hello.h"

hello::hello(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::hello)
{
    ui->setupUi(this);
    Phonon::VideoPlayer *player = new Phonon::VideoPlayer(Phonon::VideoCategory,this);
    
}

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

void hello::on_pushButton_Quit_clicked()
{
    hello::close();
}

void hello::on_pushButton_Open_clicked()
{
    QString path;

    path = QFileDialog::getOpenFileName(this,"Open file...","/","Video(*.avi);All Files(*.*)");

    ui->lineEdit_FilePath->setText(path);

}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Adding the following line in the .pro file fixed it
QT       += phonon

Found the solution here

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial