【发布时间】:2012-05-13 18:22:10
【问题描述】:
我正在尝试在 Debian 挤压、python 2.6.6 上使用 waf 构建 simplest Boost.Asio tutorial example "timer1"(它在 timer.cpp 中)。
root@ds:/var/timer# ls
timer.cpp wscript
这里的 wscript 是 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 成功。
但waf --verbose build 以错误结束(我在下面插入<*> 以标记一行)
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']
似乎waf调用的gcc在链接过程中没有找到boost_system库。
但是,如果我通过 gcc 构建示例而不使用 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
如您所见,waf 使用的命令行(标记为<*>)与标记为<**> 的命令行相同。但结果完全不同。为什么?我怎么能强迫 waf 建造那个东西? here 的解决方案对我也不起作用。也试过了
...
opt.tool_options('boost')
...
conf.load('compiler_cxx boost')
conf.check_boost()
...
tgen.uselib = 'BOOST'
...
但没有任何影响
还有一个问题。 gcc --verbose 的输出比 waf --verbose 的输出要广泛得多。在我看来,verbose 选项必须强制 waf 显示所有此类信息。为什么那不是真的? waf 选项 -vvv 也不显示此信息。
【问题讨论】: