Home > Backend Development > C++ > body text

Why Does g Still Throw \'Enable Multithreading to use std::thread: Operation not permitted\' Even With -pthread Flag?

Barbara Streisand
Release: 2024-10-31 12:46:18
Original
356 people have browsed it

Why Does g   Still Throw

Compiling Multithread Code with g

An individual encountered difficulty compiling multithread code using g , despite specifying the necessary flags. The code, which includes header files for I/O and thread manipulation, was straightforward, containing a worker thread and a main thread. However, the compilation attempt resulted in an error:

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

The individual had already included the -pthread flag in their compilation command, which is typically recommended to enable multithreading in g . However, the issue persisted.

The answer to the problem stems from a bug in gcc. The workaround suggested in the last comment of the relevant bug discussion involves adding the following flag to the compilation command:

-Wl,--no-as-needed
Copy after login

By implementing this workaround, the individual was able to successfully compile and run their multithread code using g .

The above is the detailed content of Why Does g Still Throw \'Enable Multithreading to use std::thread: Operation not permitted\' Even With -pthread Flag?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!