# windows install gcc, g++, pthread

Windows installation gcc, g++, pthread

When using the pthread function on Windows, an error is reported: the source file <pthread.h> cannot be opened, usually because the pthread library is missing. This article records the operation process of installing gcc, g++, pthread on windows .

Windows can install gcc, g++, and pthread in the form of mingw.

STEP 1: Download the mingw file

Open the webpage https://sourceforge.net/projects/mingw/files/ and download mingw-get-setup.exe

insert image description here

STEP 2: Install.exe

Run mingw-get-setup.exe to install mingw, you need to pay attention to the installation directory, remember the installation directory, you will need to set environment variables to use later.

STEP 3: Environment variable configuration

You need to modify the environment variable. Select Computer—Properties—Advanced System Settings—Environment Variables, find the Path variable in the system variables, and add the bin file directory under the min-gw installation directory, such as C:\MinGw\bin

insert image description here

STEP 4: Confirm that the installation of MinGw is successful

Win+r to open cmd, enter mingw-get, and the window of MinGw installation manager will pop up, which proves that the installation of MinGW is successful. At this time, the window of MinGW needs to be closed, otherwise an error will be reported.

insert image description here

STEP 5: Install gcc

Enter the command in the cmd window: mingw-get install gcc to install gcc

insert image description here

STEP 6: Install g++

Enter the commands mingw-get install g++ and mingw-get install gdb

insert image description here

STEP 7: View gcc

Enter gcc -v in cmd to check whether the gcc installation is successful
insert image description here

STEP 8: Install pthreads

Enter the command mingw-get install pthreads

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-qCjRv1UY-1690966284433)(https://s3-us-west-2.amazonaws.com/secure.notion -static.com/4b25bdf0-0ffa-4179-88ae-9668e4152c34/Untitled.png)]

Use windows with vscode

Terminal input gcc -v

insert image description here

Compile Linux multithreaded code

Enter gcc main.c thrd_pool.c -o main -lpthread
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44477424/article/details/132066531