I am writing a C++ program and I'm using QT for the GUI. I need to pass data from a QT thread to another, so I decided to use an external variable but it does not work. This is my code:
stream_buffer.h
#ifndef STREAM_BUFFER_H
#define STREAM_BUFFER_H
#include "opencv2/core.hpp"
extern cv::Mat frame_buffer;
#endif // STREAM_BUFFER_H
Thread1.cpp
#include "stream_buffer.h"
//Some code
cv::Mat frame_buffer;
video_stream >> frame_buffer;
//other code
Thread2.cpp
#include "stream_buffer.h
imshow("debug", frame_buffer);
During the compilation, I get the error unresolved external symbol frame_buffer in function void run in Thread2.cpp
. If I define the frame_buffer
variable also in Thread2.cpp it compiles but of course it does not work (since it is a local variable so it doesn't read the value from the common header file).
How can I solve this problem? Thanks