Home c++ g ++ says to include a library that already includes

g ++ says to include a library that already includes




The errors associated with the curves of the name is not

The very mistake – trying to make a list of streams, but the ‘flow’ is declared was not

This thread library is included

Part of the code which I am trying parallels

int division = poolsize / threads;
thread threadList [threads] {};
for (int i = 0; i & lt; threads-1; ++ i) {
  thread threadList [i] (...);
thread threadList [threads-1] (...);

compiled g ++ -Wall -o name.exe code.cpp

Operating system – Windows 7 64bit

Well, see if I can generally create threads

# include & lt; thread & gt;
void nothing () {}
std :: thread a (nothing);}

The compiler gives an error – std :: thread is not declared, add #include thread


gcc downloaded to the first available site (https://programforyou.ru/poleznoe/kak-ustanovit-gcc-dlya-windows) (ftp://ftp.equation.com/gcc/gcc -9.2.0-64.exe)

On the #include compiler does not swear

-std = C++ 11 nothing has changed

In the file, all the thread lies under #if defined (_GLIBCXX_HAS_GTHREADS), it can somehow influence?

Answer 1, Authority 100%

This is a normal behavior of gcc. You must specify the appropriate flag to the linker.

There is a man on gcc – man_gcc

Here’s an excerpt that you should be interested in –

Add support for multithreading using the POSIX threads library. This option sets flags for both the preprocessor and linker. It does not affect the thread safety of object code produced by the compiler or that of libraries supplied with it. These are HP-UX specific flags.

Collect all the flag -pthread

gcc -std = C++ 17 -pthread * blah blah blah *


gcc -std = C++ 17 MyProgram.c -o MyProgram -lpthread

standard specifies at least 11!

P.S. zainklyudit header files and library linkankut – do different things in principle)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions