Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » 'Thread' has not been declared (Problem to compile example with thread)
'Thread' has not been declared [message #47054] Tue, 22 November 2016 13:33 Go to next message
lovmy is currently offline  lovmy
Messages: 44
Registered: November 2015
Member

Hi !

I try to compile httpServer example on Windows version of TheIDE with MinGW.
I have error:

'Thread' has not been declared

This is the source:

#include <Core/Core.h>

using namespace Upp;

TcpSocket   server;
StaticMutex ServerMutex;

void Server()
{
	for(;;) {
		TcpSocket socket;
		LOG("Waiting...");
		ServerMutex.Enter();
		bool b = socket.Accept(server);
		ServerMutex.Leave();
		if(b) {
			LOG("Connection accepted");
			HttpHeader http;
			http.Read(socket);
			String html;
			html << "<html>"
			     << "<b>Method:</b> " << http.GetMethod() << "<br>"
			     << "<b>URI:</b> " << http.GetURI() << "<br>";
			for(int i = 0; i < http.fields.GetCount(); i++)
				html << "<b>" << http.fields.GetKey(i) << ":</b> " << http.fields[i] << "<br>";
			int len = (int)http.GetContentLength();
			if(len > 0)
				socket.GetAll(len);
			html << "<b><i>Current time:</i></b> " << GetSysTime() << "</html>";
			HttpResponse(socket, http.scgi, 200, "OK", "text/html", html);
		}
	}
}

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_COUT|LOG_FILE);

	if(!server.Listen(4000, 10)) {
		LOG("Cannot open server port for listening\r\n");
		return;
	}
	const int NTHREADS = 10;
	for(int i = 0; i < NTHREADS; i++)
		Thread::Start(callback(Server));
	Server();
}


What's the problem ?

Thank you for your help !
Re: 'Thread' has not been declared [message #47055 is a reply to message #47054] Tue, 22 November 2016 19:44 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
lovmy wrote on Tue, 22 November 2016 13:33
Hi !

I try to compile httpServer example on Windows version of TheIDE with MinGW.
I have error:

'Thread' has not been declared


Do you have MT flag set in the package configuration?

Re: 'Thread' has not been declared [message #47056 is a reply to message #47054] Wed, 23 November 2016 09:23 Go to previous messageGo to next message
lovmy is currently offline  lovmy
Messages: 44
Registered: November 2015
Member

Hi !

I have replaced:

mainconfig
	"" = "";


by

mainconfig
	"" = "MT";


in upp file and now it's work !

Thank you very much !!!
Re: 'Thread' has not been declared [message #47058 is a reply to message #47056] Wed, 23 November 2016 21:36 Go to previous message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

You can select package to be MT at the package creation level. Just select "Multithreaded" or add in manually by editing flags - main TheIDE toolbar. You do not need this manually - but if you did it is OK.

@Mirek - I think we should enable MT flag by default for all new packages created via template. It is 2016 and even c++ standard supports it by default. Almost all devices now have got cores - so MT is must have.

Sincerely,
Klugier


U++ - one framework to rule them all.
Previous Topic: PromptOK(GetCurrentDirectory());
Next Topic: Index find on complex match
Goto Forum:
  


Current Time: Fri Mar 29 15:08:47 CET 2024

Total time taken to generate the page: 0.01933 seconds