Bonjour a tous,

j'essaie en vain de faire fonctionner ce code extrait d'internet sur Eclipse Neon C/C++:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "thread.h"
 
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
 
/* this function is run by the second thread */
void *inc_x(void *x_void_ptr)
{
	/* increment x to 100 */
	int *x_ptr = (int *)x_void_ptr;
	while(++(*x_ptr) < 100);
 
	printf("x increment finished\n");
	/* the function must return something - NULL will do */
	return NULL;
}
 
int main()
{
	int x = 0, y = 0;
	/* show the initial values of x and y */
	printf("x: %d, y: %d\n", x, y);
 
	/* this variable is our reference to the second thread */
 
	pthread_t inc_x_thread;
 
	/* create a second thread which executes inc_x(&x) */
 
	if(pthread_create(&inc_x_thread, NULL, inc_x, &x)) {
		fprintf(stderr, "Error creating thread\n");
		return 1;
	}
 
 
 
	/* increment y to 100 in the first thread */
	while(++y < 100);
 
	printf("y increment finished\n");
 
	/* wait for the second thread to finish */
	if(pthread_join(inc_x_thread, NULL)) {
 
		fprintf(stderr, "Error joining thread\n");
		return 2;
 
	}
 
	/* show the results - x is now 100 thanks to the second thread */
	printf("x: %d, y: %d\n", x, y);
 
	return 0;
 
}
Ayant normalement téléchargé le compilateur et importé la bibliothèque; Lorque je compile j'ai le message d erreur suivant. Avez vous deja eut ce probleme?

Building target: test2
Invoking: Cross GCC Linker
gcc -o "test2" ./thread.o -l"C:/MinGW/lib/libpthread.a"
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lC:/MinGW/lib/libpthread.a
collect2.exe: erreur: ld a retourné 1 code d'état d'exécution
make: *** [test2] Error 1

Merci d'avance pour vos réponses,

Bien à vous.

beau_g