C++ Qt unresolved external symbol "public: virtual __thiscall



  • Please help
    I have this class

    videosettings.h
    @#ifndef VIDEOSETTINGS_H
    #define VIDEOSETTINGS_H
    #include <QDialog>
    #include <QAudioEncoderSettings>
    #include <QVideoEncoderSettings>

    class QComboBox;
    class QMediaRecorder;
    namespace Ui { class VideoSettingsUi; }

    class VideoSettings : public QDialog
    {
    Q_OBJECT

    public:
    VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = 0);
    ~VideoSettings();

    QAudioEncoderSettings audioSettings() const;
    void setAudioSettings(const QAudioEncoderSettings&);
    

    void setVideoSettings(const QVideoEncoderSettings&);

    protected:
    void changeEvent(QEvent *e);

    private:
    QVariant boxValue(const QComboBox*) const;
    Ui::VideoSettingsUi *ui;
    QMediaRecorder *mediaRecorder;
    };

    #endif

    videosettings.cpp

    @#include "videosettings.h"
    #include "ui_videosettings.h"

    #include <QComboBox>
    #include <QDebug>
    #include <QMediaRecorder>
    #include <QMediaService>

    VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::VideoSettingsUi),
    mediaRecorder(mediaRecorder)
    {
    ui->setupUi(this);
    ui->audioCodecBox->addItem(tr("Default audio codec"), QVariant(QString()));
    foreach (const QString &codecName, mediaRecorder->supportedAudioCodecs()) {
    QString description = mediaRecorder->audioCodecDescription(codecName);
    ui->audioCodecBox->addItem(codecName+": "+description, QVariant(codecName));
    }

    foreach (int sampleRate, mediaRecorder->supportedAudioSampleRates()) {
        ui->audioSampleRateBox->addItem(QString::number(sampleRate), QVariant(sampleRate));
    }
    
    ui->audioQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality));
    
    ui->videoCodecBox->addItem(tr("Default video codec"), QVariant(QString()));
    foreach (const QString &codecName, mediaRecorder->supportedVideoCodecs()) {
        QString description = mediaRecorder->videoCodecDescription(codecName);
        ui->videoCodecBox->addItem(codecName+": "+description, QVariant(codecName));
    }
    
    ui->videoQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality));
    
    ui->videoResolutionBox->addItem(tr("Default"));
    QList<QSize> supportedResolutions = mediaRecorder->supportedResolutions();
    foreach (const QSize &resolution, supportedResolutions) {
        ui->videoResolutionBox->addItem(QString("%1x%2").arg(resolution.width()).arg(resolution.height()),
                                        QVariant(resolution));
    }
    
    ui->videoFramerateBox->addItem(tr("Default"));
    QList<qreal> supportedFrameRates = mediaRecorder->supportedFrameRates();
    qreal rate;
    foreach (rate, supportedFrameRates) {
        QString rateString = QString("%1").arg(rate, 0, 'f', 2);
        ui->videoFramerateBox->addItem(rateString, QVariant(rate));
    }
    
    //containers
    ui->containerFormatBox->addItem(tr("Default container"), QVariant(QString()));
    foreach (const QString &format, mediaRecorder->supportedContainers()) {
        ui->containerFormatBox->addItem(format+":"+mediaRecorder->containerDescription(format),
                                        QVariant(format));
    }
    

    }

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

    void VideoSettings::changeEvent(QEvent *e)
    {
    QDialog::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
    ui->retranslateUi(this);
    break;
    default:
    break;
    }
    }

    QAudioEncoderSettings VideoSettings::audioSettings() const
    {
    QAudioEncoderSettings settings = mediaRecorder->audioSettings();
    settings.setCodec(boxValue(ui->audioCodecBox).toString());
    settings.setQuality(QMultimedia::EncodingQuality(ui->audioQualitySlider->value()));
    settings.setSampleRate(boxValue(ui->audioSampleRateBox).toInt());
    return settings;
    }

    void VideoSettings::setAudioSettings(const QAudioEncoderSettings &audioSettings)
    {
    ui->audioQualitySlider->setValue(audioSettings.quality());
    }
    void VideoSettings::setVideoSettings(const QVideoEncoderSettings &videoSettings)
    {
    ui->videoQualitySlider->setValue(videoSettings.quality());
    for (int i = 0; i < ui->videoFramerateBox->count(); ++i) {
    qreal itemRate = ui->videoFramerateBox->itemData(i).value<qreal>();
    if (qFuzzyCompare(itemRate, videoSettings.frameRate())) {
    ui->videoFramerateBox->setCurrentIndex(i);
    break;
    }
    }
    }
    QVariant VideoSettings::boxValue(const QComboBox *box) const
    {
    int idx = box->currentIndex();
    if (idx == -1)
    return QVariant();

    return box->itemData(idx);
    

    }
    @
    and this class instance created and called from another class method
    @void Camera::configureVideoSettings()
    {
    VideoSettings settingsDialog(mediaRecorder);
    settingsDialog.setAudioSettings(audioSettings);
    settingsDialog.setVideoSettings(videoSettings);
    }@

    When I compile this code I get the following errors

    camera.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall VideoSettings::~VideoSettings(void)" (??1VideoSettings@@UAE@XZ) referenced in function "private: void __thiscall Camera::configureVideoSettings(void)" (?configureVideoSettings@Camera@@AAEXXZ)
    camera.obj : error LNK2019: unresolved external symbol "public: void __thiscall VideoSettings::setFormat(class QString const &)" (?setFormat@VideoSettings@@QAEXABVQString@@@Z) referenced in function "private: void __thiscall Camera::configureVideoSettings(void)" (?configureVideoSettings@Camera@@AAEXXZ)
    camera.obj : error LNK2019: unresolved external symbol "public: void __thiscall VideoSettings::setVideoSettings(class QVideoEncoderSettings const &)" (?setVideoSettings@VideoSettings@@QAEXABVQVideoEncoderSettings@@@Z) referenced in function "private: void __thiscall Camera::configureVideoSettings(void)" (?configureVideoSettings@Camera@@AAEXXZ)



  • Hi,
    inside Camera::configureVideoSettings() I dont' see your call to settingsDialog.setFormat(string), u sure it's the code above that gives those errors?

    Also, you can check if this is just a linking error, maybe by merging the two files videosettings.cpp and camera.cpp into just one .cpp file.



  • Thanks, but I downloaded this files and don't change nothing

    http://qt-project.org/doc/qt-5.0/qtmultimedia/multimediawidgets-camera.html

    videosettings.cpp and camera.cpp don't included in one .cpp.



  • Aha sorry I've not looked so much at Qt's samples!

    Anyway, I just found your code in my installation of Qt in Windows 7, in C:\Qt\5.2.1\msvc2012\examples\multimediawidgets\camera

    Double-clicked on the camera.pro file, it compiled and run just fine (except that I don't have any camera)

    So, maybe because you have another version of Windows and Visual Studio?



  • I am using Windows7 and VS 2010.
    I saw the example.

    Thank you so much!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.