Bonjours, depuis un bon momment j'essai de trouver un bon tutoriel de programmation réseau multiplateforme, bien sur, on parle toujour de boost asio dans ces cas la.

le probleme est que, boost ne m'aime vraiment pas, j'arrive pas a compilé un simple exemple d'un tutorial, pourtant, j'ai absolument toute les librairie boost, ou du moin... j'vois pas ce qui me manque dans le ubuntu software center.. en tout cas, j'vais vous montré un code que j'esai de compiler, et les build log/message dans code::block

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
 
#include <iostream>
#include <boost/array.hpp>
#include <boost/asio.hpp>
 
using boost::asio::ip::udp;
 
int main()
{
	try
	{
		boost::asio::io_service io_service;
 
		udp::endpoint receiver_endpoint (boost::asio::ip::address::from_string("127.0.0.1"), 7171);
 
		udp::socket socket(io_service); // (1)
		socket.open(udp::v4());
 
		boost::array<char, 1> send_buf  = { 0 }; // (2)
		socket.send_to(boost::asio::buffer(send_buf), receiver_endpoint); // (3)
 
		boost::array<char, 128> recv_buf; // (4)
		udp::endpoint sender_endpoint;
		size_t len = socket.receive_from(boost::asio::buffer(recv_buf), sender_endpoint); // (5)
 
		std::cout.write(recv_buf.data(), len); // (6)
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}
 
	return 0;
}
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
Compiling: /home/pierrick/test.cpp
Linking console executable: /home/pierrick/test
/home/pierrick/test.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x2ce): undefined reference to `boost::system::get_system_category()'
test.cpp:(.text+0x2da): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x2e6): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x2f2): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x2fe): undefined reference to `boost::system::get_system_category()'
/home/pierrick/test.o: In function `boost::system::error_code::error_code()':
test.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::get_system_category()'
/home/pierrick/test.o: In function `boost::asio::error::get_system_category()':
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x5): undefined reference to `boost::system::get_system_category()'
/home/pierrick/test.o: In function `boost::asio::detail::posix_thread::~posix_thread()':
test.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26): undefined reference to `pthread_detach'
/home/pierrick/test.o: In function `boost::asio::detail::posix_thread::join()':
test.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[boost::asio::detail::posix_thread::join()]+0x2b): undefined reference to `pthread_join'
/home/pierrick/test.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service<boost::asio::detail::epoll_reactor<false> > >::context>::posix_tss_ptr()':
test.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEEC2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEEC5Ev]+0x26): undefined reference to `pthread_key_create'
/home/pierrick/test.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service<boost::asio::detail::epoll_reactor<false> > >::context>::~posix_tss_ptr()':
test.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEED2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEED5Ev]+0x15): undefined reference to `pthread_key_delete'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 4 seconds)
11 errors, 0 warnings
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
/home/pierrick/test.o||In function `__static_initialization_and_destruction_0(int, int)':|
test.cpp|| undefined reference to `boost::system::get_system_category()'|
test.cpp|| undefined reference to `boost::system::get_generic_category()'|
test.cpp|| undefined reference to `boost::system::get_generic_category()'|
test.cpp|| undefined reference to `boost::system::get_generic_category()'|
test.cpp|| undefined reference to `boost::system::get_system_category()'|
/home/pierrick/test.o||In function `boost::system::error_code::error_code()':|
test.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17)||undefined reference to `boost::system::get_system_category()'|
/home/pierrick/test.o||In function `boost::asio::error::get_system_category()':|
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x5)||undefined reference to `boost::system::get_system_category()'|
/home/pierrick/test.o||In function `boost::asio::detail::posix_thread::~posix_thread()':|
test.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26)||undefined reference to `pthread_detach'|
/home/pierrick/test.o||In function `boost::asio::detail::posix_thread::join()':|
test.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[boost::asio::detail::posix_thread::join()]+0x2b)||undefined reference to `pthread_join'|
/home/pierrick/test.o||In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service<boost::asio::detail::epoll_reactor<false> > >::context>::posix_tss_ptr()':|
test.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEEC2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEEC5Ev]+0x26)||undefined reference to `pthread_key_create'|
/home/pierrick/test.o||In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service<boost::asio::detail::epoll_reactor<false> > >::context>::~posix_tss_ptr()':|
test.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEED2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEED5Ev]+0x15)||undefined reference to `pthread_key_delete'|
||=== Build finished: 11 errors, 0 warnings ===|

Merci beaucoup de votre temp... je ne compte meme plus le nombre d'heures que j'essai de trouver moyen de faire de la programmation réseau multiplateforme, et asio en standalone, je trouve pas de tuto ><