Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QtCreator: Target debug/...obj doesn't exist

Tags:

c++

qt

I'm new to C++ and Qt. My problem is, that I created a new class and it doesn't get compiled. So the compiler says: "unresolved Object in ...". This is the header:

#ifndef TRANSITIOUSPLAYER_H
#define TRANSITIOUSPLAYER_H
#include <QtMultimedia>

class TransitiousPlayer
{

public:
    TransitiousPlayer();
    TransitiousPlayer(const TransitiousPlayer &other);
    ~TransitiousPlayer();

    void play();
};
Q_DECLARE_METATYPE(TransitiousPlayer)
#endif // TRANSITIOUSPLAYER_H

class:

#include "transitiousplayer.h"

...

void TransitiousPlayer::play(){
    QMediaPlayer* player = new QMediaPlayer(this);
    QMediaPlaylist* playlist = new QMediaPlaylist(player);
    playlist->playlist->addMedia(new QString("sh.mp3"));
    player->setPlaylist(playlist);
    player->play();
}

In mainwindow.cpp:

TransitiousPlayer player;
player.play();

In main i also call:

qRegisterMetaType<TransitiousPlayer>();

If i only try to compile transitiousplayer.cpp, it says: "Target debug/transitiousplayer.obj doesn't exist."

like image 835
theporenta Avatar asked Jan 07 '14 17:01

theporenta


3 Answers

Probably too late to help, but I had the same issue and am also new to QT (5.2.0).

For some reason, if the makefile is already made, in my situation, it wouldn't add it to the makefile, even if you select 'Clean', which is what I assumed Clean would do.

The solution that worked for me was to manually delete the contents of the build directory and hit build again, in which case it recreates it. I am not sure what clean is supposed to do if not this.

I had a project with a couple of classes, which i built and ran, then made a new class with File->New File.. C++ class. Wrote my class and press run again. Got that my constructor was missing. Hit build on just that file and got the same Target Debug/...obj doesn't exist. Checked the pro file and the class source and header names were present, checked the disk, they were there, checked the Makefile.Debug and there was no trace of those files. Hit clean, it didn't change the makefile. Deleted the contents of the build-Projectname-Desktop-qt_5_2_0.. directory, hit run, and it built and ran without issue.

like image 153
Woody Avatar answered Nov 12 '22 04:11

Woody


Posted for future reference: I ran into this problem after adding a new class file, to get the new file to compile you have to run qmake under the Build menu.

like image 41
L0ngSh0t Avatar answered Nov 12 '22 02:11

L0ngSh0t


At Qt project view, select "run qmake" again. Then everything is O.K.

like image 41
Gary Avatar answered Nov 12 '22 03:11

Gary