не могу связать boost.system в makefile - PullRequest
4 голосов
/ 20 августа 2009

Только что задал вопрос о связывании библиотек Boost в файле make. Спасибо тем, кто помог с этим. Я закончил с этим:

accesstimer: acctime.o bentimer.o
    g++ -L/usr/local/boost/boost_1_39_0/stage/lib -lboost_system -lboost_filesystem   acctime.o bentimer.o -o accesstimer   

acctime.o: acctime.cpp bentimer.h
    g++ -I /usr/local/boost/boost_1_39_0 -c acctime.cpp 

bentimer.o: bentimer.cpp bentimer.h
    g++ -c bentimer.cpp 

Моя проблема сейчас в том, что boost.filesystem требует boost.system, а приведенный выше файл make не может найти boost.system.

Я получил имя для boost.filesystem, просмотрев каталог stage / lib и удалив раздел lib и конечный элемент имени файла (libboost_filesystem-gcc41-mt.a). Как вы можете видеть выше, я сделал то же самое с libboost_system-gcc41-mt.a и придумал boost_system, но его не удалось найти.

Кто-нибудь знает, как бы я связал boost.system?

Спасибо, дядя Зейв, это работает, но как только я пытаюсь использовать одно из ключевых слов файловой системы (например, существует), я получаю следующее:

g++ -I /usr/local/boost/boost_1_39_0 -c acctime.cpp
In file included from acctime.cpp:5:
bentimer.h:2:19: warning: extra tokens at end of #ifndef directive
bentimer.h:11:18: warning: extra tokens at end of #ifdef directive
bentimer.h:28:3: warning: no newline at end of file
g++ -L/usr/local/boost/boost_1_39_0/stage/lib -lboost_system-gcc41-mt -lboost_filesystem   acctime.o bentimer.o -o accesstimer
acctime.o: In function `boost::enable_if<boost::filesystem::is_basic_path<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >, bool>::type boost::filesystem::exists<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >(boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> const&)':
acctime.cpp:(.text._ZN5boost10filesystem6existsINS0_10basic_pathISsNS0_11path_traitsEEEEENS_9enable_ifINS0_13is_basic_pathIT_EEbE4typeERKS7_[boost::enable_if<boost::filesystem::is_basic_path<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >, bool>::type boost::filesystem::exists<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >(boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> const&)]+0x35): undefined reference to `boost::filesystem::detail::status_api(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::system::error_code&)'
collect2: ld returned 1 exit status
make: *** [accesstimer] Error 1

Вы знаете, что я здесь делаю неправильно?

Теперь я добавил -I Boost Root Link к первой команде ссылки, которую он прекрасно строит:

accesstimer: acctime.o bentimer.o
    g++ -L/usr/local/boost/boost_1_39_0/stage/lib -lboost_system-gcc41-mt -lboost_filesystem-gcc41-mt  -I /usr/local/boost/boost_1_39_0 acctime.o bentimer.o -o accesstimer     

acctime.o: acctime.cpp bentimer.h
    g++ -I /usr/local/boost/boost_1_39_0 -c acctime.cpp 

bentimer.o: bentimer.cpp bentimer.h
    g++ -c bentimer.cpp 

Но когда я выполняю, я получаю:

./accesstimer: error while loading shared libraries: libboost_system-gcc41-mt-1_39.so.1.39.0: cannot open shared object file: No such file or directory

Этот файл присутствует, но он не забирает его.

Ответы [ 2 ]

4 голосов
/ 20 августа 2009

На самом деле вы не должны удалять всю завершающую часть, только расширение:

-lboost_system-gcc41-mt

То же самое относится к boost_filesystem:

-lboost_filesystem-gcc41-mt
1 голос
/ 25 августа 2009

Ответ для меня, надеюсь, это поможет кому-то еще, был следующим: У меня были проблемы с линковкой, хорошие люди заставили меня внести нужные вещи в мой файл make, но я все еще получал:

./accesstimer: error while loading shared libraries: libboost_system-gcc41-mt-1_39.so.1.39.0: cannot open shared object file: No such file or directory

Решение было просто выполнить:

ldconfig

На моей машине с Linux, на которой я только что установил Boost и собрал библиотеки Filesytem. Я предполагаю, что так как ldconfig должен был быть запущен для моей системы, чтобы забрать новые библиотеки, которые я установил. Теперь это работает.

...