By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

Not able to link against boost library

P: n/a
Hi,

I don't any solution any more... I have written a small tool wich uses
the boost library. It compiles fine, but I can't link it.

I am on a Fedora Core 6 x86_64 system. The boost library is installed
with "yum install boost" - so this should be fine.

ldconfig | grep boost gives me a list with all the installed boost
libraries, including the two (libboost_filesystem.so and
libboost_regex.so) I need.

The LDFLAG is set to "-lstdc++ -newlib -libboost_regex
-libboost_filesystem", which should include the boost libraries for the
linker, as far as I know.

but when i call g++ to link my two object files to the binary, it fails:

g++ -o hrmmerge HRMmerge.o fileinfo.o -L/usr/lib64

HRMmerge.o: In function `open_files(char*)':
HRMmerge.cpp:(.text+0x1f9): undefined reference to
`boost::filesystem::path::path(char const*)'
HRMmerge.cpp:(.text+0x202): undefined reference to
`boost::filesystem::exists(boost::filesystem::path const&)'
HRMmerge.cpp:(.text+0x254): undefined reference to
`boost::filesystem::path::path(char const*)'
HRMmerge.cpp:(.text+0x29e): undefined reference to
`boost::filesystem::path::leaf() const'
HRMmerge.cpp:(.text+0x2c2): undefined reference to
`boost::filesystem::is_directory(boost::filesystem ::path const&)'
HRMmerge.o: In function
`boost::filesystem::directory_iterator::directory_ iterator(boost::filesystem::path
const&)':
HRMmerge.cpp:(.text._ZN5boost10filesystem18directo ry_iteratorC1ERKNS0_4pathE[boost::filesystem::directory_iterator::directory_i terator(boost::filesystem::path
const&)]+0x2c): undefined reference to
`boost::filesystem::detail::dir_itr_init(boost::sh ared_ptr<boost::filesystem::detail::dir_itr_imp>&,
boost::filesystem::path const&)'
HRMmerge.o: In function `boost::basic_regex<char,
boost::regex_traits<char, boost::cpp_regex_traits<char >::assign(char
const*, char const*, unsigned int)':
HRMmerge.cpp:(.text._ZN5boost11basic_regexIcNS_12r egex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEP KcS7_j[boost::basic_regex<char,
boost::regex_traits<char, boost::cpp_regex_traits<char >::assign(char
const*, char const*, unsigned int)]+0x27): undefined reference to
`boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char >::do_assign(char const*, char const*,
unsigned int)'
and so on...

Anybody an idea what to do? My c++ experience is not really fresh
anymore and I am not too familiar with g++ and building software on
linux. So I am stuck :-(

Thanks in advance!
Andreas
Sep 3 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Andreas S. wrote:

[...]
The LDFLAG is set to "-lstdc++ -newlib -libboost_regex
-libboost_filesystem", which should include the boost libraries for the
linker, as far as I know.
Try to replace -libboost_regex against -lboost_regex and
-libboost_filesystem against -lboost_filesystem in your linker call.

[...]

CU,
Daniel Kay
Sep 3 '06 #2

P: n/a
Andreas S. wrote:
The LDFLAG is set to "-lstdc++ -newlib -libboost_regex
-libboost_filesystem",
libstdc++ is automatically linked, so you should drop it. Are you sure you
need newlib? It is meant for relatively small embedded systems, which you
don't seem to be writing your code for. Then change
'-libboost_regex -libboost_filesystem'
into '-boost_regex -lboost_filesystem'
which should include the boost libraries for the
linker, as far as I know.

but when i call g++ to link my two object files to the binary, it fails:

g++ -o hrmmerge HRMmerge.o fileinfo.o -L/usr/lib64
Uhm, where are your LDFLAGS?
Anybody an idea what to do? My c++ experience is not really fresh
anymore and I am not too familiar with g++ and building software on
linux. So I am stuck :-(
As a matter of fact, you are quite off-topic here, because this newsgroup is
only about the C++ language itself, not any build tools/compilers/linkers.
I suggest something like comp.unix.programmer .
Sep 3 '06 #3

P: n/a
Daniel Kay wrote:
Andreas S. wrote:

[...]
>The LDFLAG is set to "-lstdc++ -newlib -libboost_regex
-libboost_filesystem", which should include the boost libraries for
the linker, as far as I know.

Try to replace -libboost_regex against -lboost_regex and
-libboost_filesystem against -lboost_filesystem in your linker call.

[...]

CU,
Daniel Kay
Thanks! This and changing the order of the files to link solved the
problem. :-)
Greets,
Andreas
Sep 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.