3

按照The Waf Book中给出的示例,我有下面描述的设置,它构建了一个共享库和一个静态库,然后将它们链接到一个 exe。我的系统正在运行带有 VS2013 MSVC 的 Windows 7。

当我使用示例构建时wscript,构建失败并显示:

Build failed
-> missing file: 'D:\\src\\waf-example\\demo\\build\\lib1.lib'

我注意到尽管bld.shlib使用(它添加了一个任务来构建一个名为“lib1”的共享库a.c),但构建输出显示 一个 DLL 和一个 LIB 条目,而我只期望一个 DLL 条目。

[5/8] cshlib: build\a.c.1.o -> build\lib1.dll build\lib1.lib build\lib1.dll.manifest

Waf Book显示了来自没有此问题的 Linux 系统的构建输出:

[6/8] cshlib: build/a.c.0.o -> build/liblib1.so

我怎样才能解决这个问题?谢谢。

Waf 书中的 wscript

def options(ctx):
    ctx.load('compiler_c')

def configure(ctx):
    ctx.load('compiler_c')

def build(bld):
        bld.shlib(
                source = 'a.c',
                target = 'lib1'
                )

        bld.stlib(
                source = 'b.c',
                use    = 'cshlib',
                target = 'lib2')

        bld.shlib(
                source = 'c.c',
                target = 'lib3',
                use    = 'lib1 lib2')

        bld.program(
                libpath='.',
                source = 'main.c',
                target = 'app',
                use    = 'lib3')

文件

D:\src\waf-example\demo>tree /F /A
D:.
|   a.c
|   b.c
|   c.c
|   main.c
|   waf-1.7.15
\---wscript

输出

D:\src\waf-example\demo>python waf-1.7.15 clean build --zones=runner
'clean' finished successfully (0.008s)
Waf: Entering directory `D:\src\waf-example\demo\build'
[1/8] c: a.c -> build\a.c.1.o
15:52:00 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64\\CL.exe', '/nologo', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\INCLUDE', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt', '..\\a.c', '/FC', '/c', '/Foa.c.1.o']
[2/8] c: b.c -> build\b.c.2.o
15:52:00 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64\\CL.exe', '/nologo', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\INCLUDE', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt', '..\\b.c', '/FC', '/c', '/Fob.c.2.o']
[3/8] c: c.c -> build\c.c.3.o
15:52:00 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64\\CL.exe', '/nologo', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\INCLUDE', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt', '..\\c.c', '/FC', '/c', '/Foc.c.3.o']
[4/8] c: main.c -> build\main.c.4.o
15:52:00 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64\\CL.exe', '/nologo', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\INCLUDE', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um', '/IC:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt', '..\\main.c', '/FC', '/c', '/Fomain.c.4.o']
a.c
[5/8] cshlib: build\a.c.1.o -> build\lib1.dll build\lib1.lib build\lib1.dll.manifest
15:52:00 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64\\LINK.exe', '/NOLOGO', '/MANIFEST', '/IMPLIB:lib1.lib', '/DLL', 'a.c.1.o', '/OUT:D:\\src\\waf-example\\demo\\build\\lib1.dll', '/LIBPATH:C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\LIB\\amd64', '/LIBPATH:C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\LIB\\amd64', '/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\8.1\\lib\\winv6.3\\um\\x64', '/LIBPATH:C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319', '/LIBPATH:C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\LIB\\amd64', '/LIBPATH:C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\LIB\\amd64', '/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\8.1\\References\\CommonConfiguration\\Neutral', '/LIBPATH:C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.1\\ExtensionSDKs\\Microsoft.VCLibs\\12.0\\References\\CommonConfiguration\\neutral']
b.c
[6/8] cstlib: build\b.c.2.o -> build\lib2.lib
15:52:00 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64\\LIB.exe', '/NOLOGO', '/OUT:lib2.lib', 'b.c.2.o']
c.c
main.c
15:52:00 runner ['C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x64\\MT.exe', '/NOLOGO', '-manifest', 'D:\\src\\waf-example\\demo\\build\\lib1.dll.manifest', '-outputresource:D:\\src\\waf-example\\demo\\build\\lib1.dll;2']
Waf: Leaving directory `D:\src\waf-example\demo\build'
Build failed
-> missing file: 'D:\\src\\waf-example\\demo\\build\\lib1.lib'
4

1 回答 1

1

waf 似乎要求您为 Windows 上的共享库指定一个.def 文件。使用 .def 文件是一种很好的做法,但不应该是强制性的,所以这可能是您发现的 Waf 中的一个错误。

我只是将lib1andlib3目标更改为:

bld.shlib(source = 'a.c', target = 'lib1', defs = 'a.def')
bld.shlib(source = 'c.c', target = 'lib3', 
          use = 'lib1 lib2', defs = 'c.def')

def 文件只是像这样的假人:

EXPORTS
    foo

这似乎足以让构建运行。

于 2015-09-01T13:39:31.803 回答