Reputation: 1776
I'm trying to build simplest Boost.Asio tutorial example "timer1" (it's in timer.cpp) with waf on Debian squeeze, python 2.6.6.
root@ds:/var/timer# ls
timer.cpp wscript
wscript here is a config of waf:
#! /usr/bin/env python
top = '.'
out = '.'
def options(opt):
opt.load('compiler_cxx')
def configure(conf):
conf.load('compiler_cxx')
conf.env['LINKFLAGS'] = '--verbose -L/usr/local/lib -lboost_system'
def build(bld):
tgen = bld.new_task_gen()
tgen.features = 'cxx cxxprogram'
tgen.source = 'timer.cpp'
tgen.target = 'timer'
tgen.includes = '.'
tgen.update_outputs = True
waf configure
is successfull.
But waf --verbose build
finishes with error (I inserted <*>
below to mark a line)
Waf: Entering directory `/var/timer'
[1/2] cxx: timer.cpp -> timer.cpp.1.o
[2/2] cxxprogram: timer.cpp.1.o -> timer
timer.cpp.1.o: In function `__static_initialization_and_destruction_0(int, int)':
timer.cpp:(.text+0x103): undefined reference to `boost::system::generic_category()'
timer.cpp:(.text+0x10f): undefined reference to `boost::system::generic_category()'
...
Build failed
-> task in 'timer' failed (exit status 1):
{task 38446736: cxxprogram timer.cpp.1.o -> timer}
<*>
['/usr/bin/g++', '--verbose -L/usr/local/lib -lboost_system', 'timer.cpp.1.o', '-o', '/var/timer/timer', '-Wl,-Bstatic', '-Wl,-Bdynamic']
It seems gcc called by waf didn't find boost_system library during linkage.
But everything works fine if I build example by gcc without waf.
root@ds:/var/timer# /usr/bin/g++ --verbose -I/var/flake/lib/boost timer.cpp -c -o timer.cpp.1.o
...
<**>
root@ds:/var/timer# /usr/bin/g++ --verbose -L/usr/local/lib -lboost_system timer.cpp.1.o -o timer -Wl,-Bstatic -Wl,-Bdynamic
...
root@ds:/var/timer# ls
timer.cpp timer.cpp.1.o timer wscript
As you can see command line used by waf (marked by <*>
) is identical with command line marked by <**>
. But the result is completely different. Why? And how can I force waf to build that thing? Solution from here doesn't work for me too. Also tried
...
opt.tool_options('boost')
...
conf.load('compiler_cxx boost')
conf.check_boost()
...
tgen.uselib = 'BOOST'
...
but without any effect
And another question. Output of gcc --verbose
is much more extensive than output of waf --verbose
. It seemed to me that verbose
option must force waf to display all such info. Why isn't that true? waf option -vvv doesn't display this info as well.
Upvotes: 1
Views: 1557
Reputation: 1494
If you use the boost tool, you should check the waf boost example in playground/boost, and you will see that check_boost takes arguments. It will solve your issue.
Alternatively if you don't use the tool, and using a real OS where libraries are set up in an accessible folder, you can just do:
conf.env.LIB_BOOST = ['boost_system']
...
bld(
...,
use='BOOST',
...,
)
Note for your future scripts:
Upvotes: 1
Reputation: 1776
The reason was that older Boost 1.42 binaries bundled with Debian were in /usr/lib. When I found that I tried to make /usr/local/lib more prioritive (latest Boost binaries built by b2 reside there). But I couldn't make waf to do that and than just uninstalled Boost 1.42 binaries completely and everything worked after that
Upvotes: 0