Bonjour à tous, je réclame votre aider pour comprendre et résoudre des problèmes en rapport avec la bibliothèque boost (et peut être aussi MinGW) que j'ai dans mon programme traitant des threads.
Voilà le programme :
et voilà les erreurs apparaissant dans CDT Build Console :
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 #include <iostream> #include <sstream> #include <vector> #include <boost/thread/thread.hpp> #include "nsUtil.h" // Rand() using namespace std; using namespace boost; using namespace boost::posix_time; // time_duration using namespace nsUtil; enum { KErrArg = 253 }; // Erreur d'arguments de main() typedef unsigned long long ULL_t; typedef long long LL_t; namespace { LL_t a = 0; ULL_t NbBoucles; void Incr (void) { for (int i (0); i <= NbBoucles; ++i) ++a; } // Incr () void Decr (void) { for (int i (0); i < NbBoucles; ++i) --a; } // Decr () } // namespace anonyme int main (int argc, char * argv []) { if (argc != 3) { cerr << "Usage : ThreadsEtDelais <NbThreads> <NbBoucles>\n"; return KErrArg; } unsigned NbThreads; { istringstream is (argv [1]); is >> NbThreads; } istringstream is2 (argv [2]); is2 >> NbBoucles; cout << "Nbre de threads : " << NbThreads << '\n'; vector <thread *> VThreads; for (unsigned i = NbThreads; i--; ) { VThreads.push_back (new thread (Incr)); VThreads.push_back (new thread (Decr)); } this_thread::sleep (seconds(1)); time_duration td = seconds(2); for (unsigned i = NbThreads; i--; ) { cout << "Attend la fin du thread de rang " << i << ' ' << " et d'ID " << VThreads[i]->get_id(); cout << (VThreads[i]->timed_join (td) ? " fini\n" : " pas fini\n"); } cout << a; return 0; } // main()
src\Concurrence_a.o:Concurrence_a.cxx:(.text$_ZN5boost6detail11thread_dataIPFvvEED1Ev[__ZN5boost6detail11thread_dataIPFvvEED1Ev]+0x7): undefined reference to `_imp___ZN5boost6detail16thread_data_baseD2Ev'
src\Concurrence_a.o:Concurrence_a.cxx:(.text$_ZN5boost6detail11thread_dataIPFvvEED0Ev[__ZN5boost6detail11thread_dataIPFvvEED0Ev]+0xe): undefined reference to `_imp___ZN5boost6detail16thread_data_baseD2Ev'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: src\Concurrence_a.o: bad reloc address 0xe in section `.text$_ZN5boost6detail11thread_dataIPFvvEED0Ev[__ZN5boost6detail11thread_dataIPFvvEED0Ev]'
collect2.exe: erreur: ld a retourné 1 code d'état d'exécution
J'utilise l'IDE Eclipse pour C/C++ Developers sous Windows 8, avec le compilateur MinGW et la version de ma bibliothèque Boost est 1_52_0
Je pense que mon problème viens des linkages dans les propriétés de mon projet... Voilà ceux que j'ai réalisé :
C/C++ Build -> Settings -> GCC C++ Compiler -> Includes -> Include paths -> C\Boost\boost_1_52_0
C/C++ Build -> Settings ->MinGW C++ Linker -> Libraries -> Libraries search path -> C:\Boost\boost_1_52_0
C/C++ General -> Path and Symbols -> Includes -> GNU C++ -> C:\Boost\boost_1_52_0
Merci d'avance de votre aide !
Partager