Zeerou
Zeerou

Reputation: 192

How to enable multithreading for Linux app in Visual Studio 2017

I'm currently developing an multithreaded application for Linux in VS 2017.

As Remote Linux machine I use built-in Ubuntu bash in Windows, which was the part of anniversary update.

Compilation goes fine, the build is succesful. But right after running the program following error occurs.

  terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted

I tried to fiddle with linking and compilation settings. But I just blew the entire project.

Did anybody encountered and solved this kind of problem? Thanks.

Edit: this thread was flagged as duplicate. Let me explain why I think this is different. I'm developing on Windows host with VS2017, and Im trying to achieve working debugging in VS2017. I cannot edit directly the compilation routine commands as in suggested duplicate thread.

Upvotes: 1

Views: 1807

Answers (1)

NotSoBrainy
NotSoBrainy

Reputation: 63

I know that @Andrey Turkin has already given the answer in the comments. I want to add it as Answer here as not all will read the comments. I have been searching for the same for 2 days now and @Andrey Turkin helped me solve this. Please follow his comment to clear this problem.

Assuming platform toolset is "Remote_GCC_1_0"; all you need to do is add "-pthread" to compile and link command lines. VS configuration maps most g++ options to specific configuration values, but not this one. Go to project's configuration, "C/C++ -> All Options", add "-pthread" to "Additional Options" configuration value. Go to "Linker -> All Options" and do the same.

Upvotes: 2

Related Questions