boost::asio - błąd linkowania

0

Chcę zrobić aplikację typu klient-serwer. Pomyślałem, że warto wykorzystać to co jest gotowe w booście, więc wziąłem się za naukę boost::assio. Wziąłem na warsztat przykład: http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/example/echo/blocking_tcp_echo_server.cpp
I tu zaczęły się problemy: błąd kompilacji. Okazało się, że boost z repo ubuntu jest conajmniej za stary, więc go usunąłem, ściągnąłem najnowszą wersję i zainstalowałem według wszystkich reguł (bootstrap, bjam, b2, na końcu jeszcze ldconfig). Wygląda na to, że zainstalowałem poprawnie, aczkolwiek teraz whereis boost nie zwraca nic. Ale przykładowe kody korzystające z boosta (header-only) działają.

Jednak teraz podczas próby linkowania przykładu z asio dostaję takie oto błędy:

g++  -L/usr/lib/  -lboost_filesystem -lboost_system -lboost_thread -lpthread server/main/main.cpp -o ../run/server.exe
/tmp/ccI6HQ28.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x59f): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x5a9): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x5b3): undefined reference to `boost::system::system_category()'
/tmp/ccI6HQ28.o: In function `boost::system::error_code::error_code()':
main.cpp:(.text._ZN5boost6system10error_codeC1Ev[boost::system::error_code::error_code()]+0x10): undefined reference to `boost::system::system_category()'
/tmp/ccI6HQ28.o: In function `boost::asio::error::get_system_category()':
main.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x7): undefined reference to `boost::system::system_category()'
/tmp/ccI6HQ28.o: In function `boost::thread_exception::thread_exception(int, char const*)':
main.cpp:(.text._ZN5boost16thread_exceptionC2EiPKc[boost::thread_exception::thread_exception(int, char const*)]+0x7): undefined reference to `boost::system::system_category()'
collect2: ld returned 1 exit status
make: *** [server] Błąd 1

linkuję z :

LDFLAGS := -lboost_filesystem -lboost_system -lboost_thread -lpthread

Przejrzałem co się da w google, przekompilowywałem boosta, nic nie dało...
Może ktoś miał już z tym problem i wie jak to rozwiązać

0

To jest cały log z linkowania?
Kompilowałeś boost'a tą samą wersją kompilatora co kompilujesz aplikację? Którą wersję boosta masz? Z tego co u siebie zauważyłem wersja 1.51 wymaga jeszcze dołączenia z boosta biblioteki chrono(no ale to nie te błędy).

U siebie linkuję z takimi bibliotekami -l:libboost_filesystem-mgw47-mt-1_51.a -l:libboost_system-mgw47-mt-1_51.a -l:libboost_thread-mgw47-mt-1_51.a -l:libboost_chrono-mgw47-mt-1_51.a -lws2_32 -lmswsock no ale ja używam MinGW, linkuję statycznie i pod win

0

Tak, to cały log z linkowania.
Z tą samą.
Boost 1.51.00

Problem był, że ld brał złą ścieżkę - tą gdzie był zainstalowany stary boost, a nie usunięte biblioteki. Teraz to naprawiam, jednak ciągle mam problemy. Ponieważ mimo, że daję:

INCLUDES := -I/usr/local/include/
LIBS := -L/usr/local/lib/

To ld się pluje:

/usr/bin/ld: cannot find -lboost_filesystem

Mimo, że:

rr@rr-laptop:/usr/local/lib$ ls -l|grep boost
-rwxr-x--- 1 root root      90756 2012-09-12 01:52 libboost_chrono.a
lrwxrwxrwx 1 root root         25 2012-09-12 01:52 libboost_chrono.so -> libboost_chrono.so.1.51.0
-rwxr-x--- 1 root root      39218 2012-09-12 01:52 libboost_chrono.so.1.51.0
-rwxr-x--- 1 root root     119890 2012-09-12 01:52 libboost_context.a
lrwxrwxrwx 1 root root         26 2012-09-12 01:52 libboost_context.so -> libboost_context.so.1.51.0
-rwxr-x--- 1 root root      99142 2012-09-12 01:52 libboost_context.so.1.51.0
-rwxr-x--- 1 root root     106538 2012-09-12 01:52 libboost_date_time.a
lrwxrwxrwx 1 root root         28 2012-09-12 01:52 libboost_date_time.so -> libboost_date_time.so.1.51.0
-rwxr-x--- 1 root root      81548 2012-09-12 01:52 libboost_date_time.so.1.51.0
-rwxr-x--- 1 root root       1350 2012-09-12 01:52 libboost_exception.a
-rwxr-x--- 1 root root     159818 2012-09-12 01:52 libboost_filesystem.a
lrwxrwxrwx 1 root root         29 2012-09-12 01:52 libboost_filesystem.so -> libboost_filesystem.so.1.51.0
-rwxr-x--- 1 root root     104688 2012-09-12 01:52 libboost_filesystem.so.1.51.0
-rwxr-x--- 1 root root     560304 2012-09-12 01:52 libboost_graph.a
lrwxrwxrwx 1 root root         24 2012-09-12 01:52 libboost_graph.so -> libboost_graph.so.1.51.0
-rwxr-x--- 1 root root     396631 2012-09-12 01:52 libboost_graph.so.1.51.0
-rwxr-x--- 1 root root     213366 2012-09-12 01:52 libboost_iostreams.a
lrwxrwxrwx 1 root root         28 2012-09-12 01:52 libboost_iostreams.so -> libboost_iostreams.so.1.51.0
-rwxr-x--- 1 root root     139108 2012-09-12 01:52 libboost_iostreams.so.1.51.0
-rwxr-x--- 1 root root    2072126 2012-09-12 01:52 libboost_locale.a
lrwxrwxrwx 1 root root         25 2012-09-12 01:52 libboost_locale.so -> libboost_locale.so.1.51.0
-rwxr-x--- 1 root root    1058233 2012-09-12 01:52 libboost_locale.so.1.51.0
-rwxr-x--- 1 root root     649948 2012-09-12 01:52 libboost_math_c99.a
-rwxr-x--- 1 root root     568948 2012-09-12 01:52 libboost_math_c99f.a
lrwxrwxrwx 1 root root         28 2012-09-12 01:52 libboost_math_c99f.so -> libboost_math_c99f.so.1.51.0
-rwxr-x--- 1 root root     208636 2012-09-12 01:52 libboost_math_c99f.so.1.51.0
-rwxr-x--- 1 root root     582310 2012-09-12 01:52 libboost_math_c99l.a
lrwxrwxrwx 1 root root         28 2012-09-12 01:52 libboost_math_c99l.so -> libboost_math_c99l.so.1.51.0
-rwxr-x--- 1 root root     208504 2012-09-12 01:52 libboost_math_c99l.so.1.51.0
lrwxrwxrwx 1 root root         27 2012-09-12 01:52 libboost_math_c99.so -> libboost_math_c99.so.1.51.0
-rwxr-x--- 1 root root     228548 2012-09-12 01:52 libboost_math_c99.so.1.51.0
-rwxr-x--- 1 root root    2549470 2012-09-12 01:52 libboost_math_tr1.a
-rwxr-x--- 1 root root    2646390 2012-09-12 01:52 libboost_math_tr1f.a
lrwxrwxrwx 1 root root         28 2012-09-12 01:52 libboost_math_tr1f.so -> libboost_math_tr1f.so.1.51.0
-rwxr-x--- 1 root root     455522 2012-09-12 01:52 libboost_math_tr1f.so.1.51.0
-rwxr-x--- 1 root root    2567058 2012-09-12 01:52 libboost_math_tr1l.a
lrwxrwxrwx 1 root root         28 2012-09-12 01:52 libboost_math_tr1l.so -> libboost_math_tr1l.so.1.51.0
-rwxr-x--- 1 root root     427177 2012-09-12 01:52 libboost_math_tr1l.so.1.51.0
lrwxrwxrwx 1 root root         27 2012-09-12 01:52 libboost_math_tr1.so -> libboost_math_tr1.so.1.51.0
-rwxr-x--- 1 root root     422901 2012-09-12 01:52 libboost_math_tr1.so.1.51.0
-rwxr-x--- 1 root root      90942 2012-09-12 01:52 libboost_prg_exec_monitor.a
lrwxrwxrwx 1 root root         35 2012-09-12 01:52 libboost_prg_exec_monitor.so -> libboost_prg_exec_monitor.so.1.51.0
-rwxr-x--- 1 root root      77873 2012-09-12 01:52 libboost_prg_exec_monitor.so.1.51.0
-rwxr-x--- 1 root root     882478 2012-09-12 01:52 libboost_program_options.a
lrwxrwxrwx 1 root root         34 2012-09-12 01:52 libboost_program_options.so -> libboost_program_options.so.1.51.0
-rwxr-x--- 1 root root     495677 2012-09-12 01:52 libboost_program_options.so.1.51.0
-rwxr-x--- 1 root root     556104 2012-09-12 01:52 libboost_python.a
lrwxrwxrwx 1 root root         25 2012-09-12 01:52 libboost_python.so -> libboost_python.so.1.51.0
-rwxr-x--- 1 root root     397240 2012-09-12 01:52 libboost_python.so.1.51.0
-rwxr-x--- 1 root root      10426 2012-09-12 01:52 libboost_random.a
lrwxrwxrwx 1 root root         25 2012-09-12 01:52 libboost_random.so -> libboost_random.so.1.51.0
-rwxr-x--- 1 root root      17320 2012-09-12 01:52 libboost_random.so.1.51.0
-rwxr-x--- 1 root root    2139870 2012-09-12 01:52 libboost_regex.a
lrwxrwxrwx 1 root root         24 2012-09-12 01:52 libboost_regex.so -> libboost_regex.so.1.51.0
-rwxr-x--- 1 root root    1265937 2012-09-12 01:52 libboost_regex.so.1.51.0
-rwxr-x--- 1 root root    1022622 2012-09-12 01:52 libboost_serialization.a
lrwxrwxrwx 1 root root         32 2012-09-12 01:52 libboost_serialization.so -> libboost_serialization.so.1.51.0
-rwxr-x--- 1 root root     645852 2012-09-12 01:52 libboost_serialization.so.1.51.0
-rwxr-x--- 1 root root     151738 2012-09-12 01:52 libboost_signals.a
lrwxrwxrwx 1 root root         26 2012-09-12 01:52 libboost_signals.so -> libboost_signals.so.1.51.0
-rwxr-x--- 1 root root     109418 2012-09-12 01:52 libboost_signals.so.1.51.0
-rwxr-x--- 1 root root      15502 2012-09-12 01:52 libboost_system.a
lrwxrwxrwx 1 root root         25 2012-09-12 01:52 libboost_system.so -> libboost_system.so.1.51.0
-rwxr-x--- 1 root root      20149 2012-09-12 01:52 libboost_system.so.1.51.0
-rwxr-x--- 1 root root    1484490 2012-09-12 01:52 libboost_test_exec_monitor.a
-rwxr-x--- 1 root root     227846 2012-09-12 01:52 libboost_thread.a
lrwxrwxrwx 1 root root         25 2012-09-12 01:52 libboost_thread.so -> libboost_thread.so.1.51.0
-rwxr-x--- 1 root root     162907 2012-09-12 01:52 libboost_thread.so.1.51.0
-rwxr-x--- 1 root root      30982 2012-09-12 01:52 libboost_timer.a
lrwxrwxrwx 1 root root         24 2012-09-12 01:52 libboost_timer.so -> libboost_timer.so.1.51.0
-rwxr-x--- 1 root root      23812 2012-09-12 01:52 libboost_timer.so.1.51.0
-rwxr-x--- 1 root root    1646188 2012-09-12 01:52 libboost_unit_test_framework.a
lrwxrwxrwx 1 root root         38 2012-09-12 01:52 libboost_unit_test_framework.so -> libboost_unit_test_framework.so.1.51.0
-rwxr-x--- 1 root root     946946 2012-09-12 01:52 libboost_unit_test_framework.so.1.51.0
-rwxr-x--- 1 root root    3091652 2012-09-12 01:52 libboost_wave.a
lrwxrwxrwx 1 root root         23 2012-09-12 01:52 libboost_wave.so -> libboost_wave.so.1.51.0
-rwxr-x--- 1 root root    1720306 2012-09-12 01:52 libboost_wave.so.1.51.0
-rwxr-x--- 1 root root     717230 2012-09-12 01:52 libboost_wserialization.a
lrwxrwxrwx 1 root root         33 2012-09-12 01:52 libboost_wserialization.so -> libboost_wserialization.so.1.51.0
-rwxr-x--- 1 root root     475954 2012-09-12 01:52 libboost_wserialization.so.1.51.0

//EDIT:

sudo chmod -R +r .

załatwiło sprawę. Chyba czas iść spać.

Dzięki za pomoc @byku_guzio

1 użytkowników online, w tym zalogowanych: 0, gości: 1