I'm developing software in c ++ that captures images from WebCam, before I used OpenCv but received an error from
Undefined symbols for architecture x86_64Until I opened a topic here and no one knew how to answer the error. Give up using OpenCv and proceeded to use QCamera's QT. So far so good, the problem is that now I wanted to update with a Thread a QLabel but when I do the emit command I get the same error when I used OpenCv. Here's the code I'm using: Home thread.h
#ifndef THREAD_H
#define THREAD_H
#include <QtCore>
class Thread : public QThread {
private:
void run();
signals:
void MySignal( void );
};
#endif // THREAD_H
thread.cpp
#include "thread.h"
#include <iostream>
#include <thread>
#include <QtCore>
using namespace std;
void Thread::run(){
qDebug()<<"From worker thread: "<<currentThreadId();
emit MySignal();
}
Button that triggers Thread:
void MainWindow::on_pushButton_clicked() {
qDebug()<<"From main thread: "<<QThread::currentThreadId();
Thread t;
QObject::connect( &t, SIGNAL( MySignal() ), this, SLOT( MySlot() ) );
t.start();
}
Error Output:
12:11:55: Running steps for project CameraControl...
12:11:55: Configuration unchanged, skipping qmake step.
12:11:55: Starting: "/usr/bin/make"
Undefined symbols for architecture x86_64:
"Thread::MySignal()", referenced from:
Thread::run() in thread.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [CameraControl.app/Contents/MacOS/CameraControl] Error 1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.10.3 -Wl,-rpath,/Applications/QTFiles/5.4/clang_64/lib -o CameraControl.app/Contents/MacOS/CameraControl main.o mainwindow.o thread.o moc_mainwindow.o -F/Applications/QTFiles/5.4/clang_64/lib -framework QtMultimediaWidgets -framework QtMultimedia -framework QtNetwork -framework QtCore -framework DiskArbitration -framework IOKit -framework QtGui -framework QtWidgets -framework OpenGL -framework AGL
12:11:55: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project CameraControl (kit: Desktop Qt 5.4.2 clang 64bit)
When executing step "Make"
12:11:55: Elapsed time: 00:00.
.Pro File
#-------------------------------------------------
#
# Project created by QtCreator 2015-06-27T21:51:05
#
#-------------------------------------------------
QT += core gui
QT += multimedia multimediawidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = CameraControl
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
thread.cpp
HEADERS += mainwindow.h \
thread.h
FORMS += mainwindow.ui
target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/camera
INSTALLS += target
mainwindow.cpp
void MySlot( void ){
qDebug() << "slot called";
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <qcamera.h>
#include <QCameraImageCapture>
#include <QMediaRecorder>
#include <qcamerainfo.h>
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void setCamera(const QCameraInfo &cameraInfo);
void updateCaptureMode();
void processSavedImage(int requestId, QString str);
void task();
void on_actionSobre_triggered();
void on_pushButton_clicked();
signals:
void signal();
public:
Ui::MainWindow *ui;
private:
QCamera *camera;
QCameraImageCapture *imageCapture;
QMediaRecorder* mediaRecorder;
QImageEncoderSettings imageSettings;
QAudioEncoderSettings audioSettings;
QVideoEncoderSettings videoSettings;
QString videoContainerFormat;
bool isCapturingImage;
bool applicationExiting;
};
#endif // MAINWINDOW_H