I had a problem creating a static VC ++ library that uses standard C ++ 11 streams.
I currently have two classes, and I can declare, and then define a thread that just works fine for my start class (which is declared last). At this point, the code is only a socket listener, which then creates an object of another class to process each received client. These children must create the streams necessary for parallel data collection, coding, and transmission.
The problem is this: if I declare std :: thread in my other class, even if it is exactly the same as in my start class, it doesn't matter, I get this error when building error C2280: 'std::thread::thread(const std::thread &)' : attempting to reference a deleted function [...]\vc\include\functional 1124 1
The only way I was able to get around this error was to simply not declare the std::thread object in the last class, which is impossible, according to what I want it to execute ...
I am using VS2013, and my sources are:
stdafx.h
#pragma once #include "targetver.h" #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include <Windows.h> #include <WinSock2.h> #include <WS2tcpip.h> #include <thread> #include <iostream> #include <vector>
StreamServer.h
#pragma once #define DEFAULT_BUFLEN 65535 #define DEFAULT_PORT "5649" class StreamServerClient { public: bool* terminate;
StreamServer.cpp
#include "stdafx.h" #include "StreamServer.h" StreamServerClient::StreamServerClient(SOCKET clientSock, bool* ptTerm) { terminate = ptTerm;
c ++ multithreading c ++ 11 visual-c ++ visual-studio-2013
Mismatch
source share