Bonsoir,
Je suis débutant avec boost, et je tente de compiler un premier programme :
voici mon fichier main :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <boost/thread.hpp>
#include <iostream>
using namespace std;
 
void test(){
	cout << "coucou" << endl;
}
 
 
int main(){
	boost::thread t(&test);
	return 0;
}
J'ai installé boost "normalement" sur ubuntu 9.10, par le gestionnaire de packet (libboost-dev)

Voici ce que j'obtient :
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
g++ test.cpp 
/tmp/cc37OBcu.o: In function `main':
test.cpp:(.text+0x5d): undefined reference to `boost::thread::~thread()'
/tmp/cc37OBcu.o: In function `boost::mutex::mutex()':
test.cpp:(.text._ZN5boost5mutexC1Ev[boost::mutex::mutex()]+0x4b): undefined reference to `boost::thread_resource_error::thread_resource_error()'
test.cpp:(.text._ZN5boost5mutexC1Ev[boost::mutex::mutex()]+0x50): undefined reference to `boost::thread_resource_error::~thread_resource_error()'
test.cpp:(.text._ZN5boost5mutexC1Ev[boost::mutex::mutex()]+0x55): undefined reference to `typeinfo for boost::thread_resource_error'
/tmp/cc37OBcu.o: In function `boost::condition_variable::condition_variable()':
test.cpp:(.text._ZN5boost18condition_variableC1Ev[boost::condition_variable::condition_variable()]+0x3f): undefined reference to `boost::thread_resource_error::thread_resource_error()'
test.cpp:(.text._ZN5boost18condition_variableC1Ev[boost::condition_variable::condition_variable()]+0x44): undefined reference to `boost::thread_resource_error::~thread_resource_error()'
test.cpp:(.text._ZN5boost18condition_variableC1Ev[boost::condition_variable::condition_variable()]+0x49): undefined reference to `typeinfo for boost::thread_resource_error'
/tmp/cc37OBcu.o: In function `boost::detail::thread_data_base::thread_data_base()':
test.cpp:(.text._ZN5boost6detail16thread_data_baseC2Ev[boost::detail::thread_data_base::thread_data_base()]+0x26): undefined reference to `vtable for boost::detail::thread_data_base'
/tmp/cc37OBcu.o: In function `boost::thread::thread<void (*)()>(void (*)(), boost::disable_if<boost::is_convertible<void (*&)(), boost::detail::thread_move_t<void (*)()> >, boost::thread::dummy*>::type)':
test.cpp:(.text._ZN5boost6threadC1IPFvvEEET_NS_10disable_ifINS_14is_convertibleIRS4_NS_6detail13thread_move_tIS4_EEEEPNS0_5dummyEE4typeE[boost::thread::thread<void (*)()>(void (*)(), boost::disable_if<boost::is_convertible<void (*&)(), boost::detail::thread_move_t<void (*)()> >, boost::thread::dummy*>::type)]+0x42): undefined reference to `boost::thread::start_thread()'
/tmp/cc37OBcu.o: In function `boost::detail::thread_data<void (*)()>::~thread_data()':
test.cpp:(.text._ZN5boost6detail11thread_dataIPFvvEED1Ev[boost::detail::thread_data<void (*)()>::~thread_data()]+0x1f): undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/tmp/cc37OBcu.o: In function `boost::detail::thread_data<void (*)()>::~thread_data()':
test.cpp:(.text._ZN5boost6detail11thread_dataIPFvvEED0Ev[boost::detail::thread_data<void (*)()>::~thread_data()]+0x1f): undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/tmp/cc37OBcu.o:(.rodata._ZTIN5boost6detail11thread_dataIPFvvEEE[typeinfo for boost::detail::thread_data<void (*)()>]+0x10): undefined reference to `typeinfo for boost::detail::thread_data_base'
collect2: ld returned 1 exit status
Je pensais qu'il falait passer un "-lboost" par exemple, mais j'ai lu que il n'y en avais pas besoin sauf quelques cas particuliers... Du coup, je sais pas.

J'ai vu beaucoup de forum avec ce genre de problème, mais trouvé aucune solution...

Merci de votre aide !