C++ Visual Studio 2017 linux can';如果有';线程

C++ Visual Studio 2017 linux can';如果有';线程,c++,linux,multithreading,visual-studio,compiler-errors,C++,Linux,Multithreading,Visual Studio,Compiler Errors,所以我尝试使用Visual Studio 2017创建一个Linux项目。 我从一个空的Linux项目开始(作为项目模板),到目前为止一切都很好 然而,如果我有 // Create a new thread for the connection to avoid clutter std::thread newConnectionHandler(connectionHandler, iNewConnection); newConnectionHandler.detach(); 在我的代码中,它不

所以我尝试使用Visual Studio 2017创建一个Linux项目。 我从一个空的Linux项目开始(作为项目模板),到目前为止一切都很好

然而,如果我有

// Create a new thread for the connection to avoid clutter
std::thread newConnectionHandler(connectionHandler, iNewConnection);
newConnectionHandler.detach();
在我的代码中,它不会编译。以下是我得到的错误:

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
编辑: 这里还有
connectionHandler
的声明:

void connectionHandler(int iConnection)

当传递
iNewConnection
时,数据类型是一个
int

-pthread
选项放入
链接器->命令行->附加选项时,它也应该是链接命令行中所有对象和库文件之后的最后一个选项


顺序很重要。

将-pthread放入链接器->命令行->其他选项起作用。即使您使用的是linux项目,也需要在visual studio中选择项目属性


谢谢

@chris好的,完成了。你在摆弄链接器,但你的错误是编译器错误。我认为你的头路径是错误的。@Quentin,也许我应该保留我原始评论的这一半,但第一个错误是Intellisense,其余的是链接器输出,这意味着编译器可以处理它。@chris oh,好的。那么,我没有更好的建议:)@Kordnak:link命令行中的
-pthread
是在所有对象和库文件之后的最后一个吗?你说的“还不够”是什么意思?我刚刚用一个新的Linux空项目进行了测试,将
-pthread
添加到链接器的附加选项中就是我所需要做的。你在评论中说,这就是解决问题的方法,对吗?如果它在任何位置都有效,请确认,我将删除此答案。嗨,arimaknp,欢迎来到StackOverflow。如果另一个答案为你解决了问题,请考虑投票,而不是增加一个副本。这将帮助其他用户快速找到答案,减少混淆
void connectionHandler(int iConnection)