So I'm trying to use Visual Studio 2017 to create a Linux project. I started out with an Empty Linux Project (as the project template), and so far everything is fine.
However, if I have
// Create a new thread for the connection to avoid clutter
std::thread newConnectionHandler(connectionHandler, iNewConnection);
newConnectionHandler.detach();
in my code, it won't compile. These are the errors that I get:
Error E0020 identifier "__float128" is undefined
Error In function `std::thread::thread<void(&)(int), int&>(void(&)(int), int&)':
Error undefined reference to `pthread_create'
Error ld returned 1 exit status
But as soon as I comment out the std::thread stuff, it compiles.
Here's what I've tried so far:
- C/C++ -> Additional Options -> Added
-pthread -lpthreador just-pthread - Linker -> Additional Options -> Added
-pthread -lpthreador just-pthread - Linker -> Library Dependencies -> Added
thread - Switching C++ Language standard between C++17 and C++11
And of course I've tried multiple variations of those changes, but I always get the same error.
And my includes are:
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <thread>
EDIT:
Here's also the declaration of connectionHandler:
void connectionHandler(int iConnection)
And when passing iNewConnection, the datatype is an int.