Not able to link against boost library

A

Andreas S.

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._ZN5boost10filesystem18directory_iteratorC1ERKNS0_4pathE[boost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path
const&)]+0x2c): undefined reference to
`boost::filesystem::detail::dir_itr_init(boost::shared_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_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_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
 
D

Daniel Kay

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
 
R

Rolf Magnus

Andreas said:
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 .
 
A

Andreas S.

Daniel said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top