c++ - I cannot build boost_regex code because of link erros -
i'm trying use boost_regex on ubuntu 12.04 (gcc 4.8.2).
i've installed boost this.
$ sudo apt-get install libboost-all-dev
and i've confirmed boost_regex libraries installed on.
$ ls /usr/lib/x86_64-linux-gnu | grep regex libboost_regex.a libboost_regex.so libboost_regex.so.1.54.0
then, i've tried build regex program code. faced link errors. should add link libraries?
#include <boost/regex.hpp> #include <iostream> #include <string> int main() { std::string line; boost::regex pat( "^subject: (re: |aw: )*(.*)" ); while (std::cin) { std::getline(std::cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) std::cout << matches[2] << std::endl; } } $ g++ -wall -std=c++11 -o out test2.cc -lboost_regex /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `icu_52::locale::~locale()' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `u_chartype_52' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `icu_52::locale::locale(icu_52::locale const&)' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `u_digit_52' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `icu_52::collator::createinstance(icu_52::locale const&, uerrorcode&)' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `icu_52::locale::locale()' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `u_charfromname_52' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `u_tolower_52' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `u_isspace_52' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_regex.so: undefined reference `u_isblank_52' collect2: error: ld returned 1 exit status
package libboost-dev-all
depends on (using dpkg --status
):
libboost-dev libboost-tools-dev libboost-atomic-dev libboost-chrono-dev libboost-context-dev libboost-coroutine-dev libboost-date-time-dev libboost-exception-dev libboost-filesystem-dev libboost-graph-dev libboost-graph-parallel-dev libboost-iostreams-dev libboost-locale-dev libboost-log-dev libboost-math-dev libboost-mpi-dev libboost-mpi-python-dev libboost-program-options-dev libboost-python-dev libboost-random-dev libboost-regex-dev libboost-serialization-dev libboost-signals-dev libboost-system-dev libboost-test-dev libboost-thread-dev libboost-timer-dev libboost-wave-dev
as can see, e.g. libboost-regex-dev
doesn't contain libraries:
$ dpkg --listfiles libboost-regex-dev /. /usr /usr/share /usr/share/doc /usr/share/doc/libboost-regex-dev /usr/share/doc/libboost-regex-dev/copyright /usr/share/doc/libboost-regex-dev/changelog.gz
that's because libboost-regex-dev
depends on libboost-regex1.54-dev
:
$ dpkg --listfiles libboost-regex1.54-dev /. /usr /usr/share /usr/share/doc /usr/share/doc/libboost-regex1.54-dev /usr/share/doc/libboost-regex1.54-dev/copyright /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libboost_regex.a /usr/share/doc/libboost-regex1.54-dev/changelog.debian.gz /usr/lib/x86_64-linux-gnu/libboost_regex.so
ah! requires icu:
$ ldd /usr/lib/x86_64-linux-gnu/libboost_regex.so linux-vdso.so.1 => (0x00007ffc265fb000) libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007feb20dc0000) libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007feb209b9000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007feb2063d000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007feb20426000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007feb20208000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007feb1fe43000) libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007feb1e5d6000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007feb1e3d2000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007feb1e0cc000) /lib64/ld-linux-x86-64.so.2 (0x00007feb21440000)
so, provides that?
$ dpkg --search /usr/lib/x86_64-linux-gnu/libicuuc.so.52 libicu52:amd64: /usr/lib/x86_64-linux-gnu/libicuuc.so.52
there's clue:
solution
$ sudo apt-get install libicu52
Comments
Post a Comment