使用 vala 库和 waf 编译 vala 应用程序
我想使用 vala 库(我编写的)和 waf 构建系统来编译 vala 应用程序。
我实际上可以使用此命令编译它:
valac -X -I/usr/local/include/ofde-1.0/ -X -lofde -o ofde-terminal src/* /usr/local/share/vala/vapi/ofde.vapi --pkg gtk+-3.0 --pkg vte-2.90 -X -DGETTEXT_PACKAGE='"ofde-terminal"'
但是,我无法使用以下 wscript 编译它:
#! /usr/bin/env python
APPNAME = 'Terminal'
PROG_NAME = 'ofde-terminal'
VERSION = '0.1'
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_c')
def configure(conf):
conf.load('compiler_c vala')
conf.check_cc(lib='ofde', uselib_store='ofde')
conf.check_cfg(package='gtk+-3.0', uselib_store='gtk+', atleast_version='3.0', args='--cflags --libs')
conf.check_cfg(package='vte-2.90', uselib_store='vte', atleast_version='0.30', args='--cflags --libs')
conf.define('PACKAGE', APPNAME)
conf.define('VERSION', VERSION)
def build(bld):
bld(
cflags = ['-DGETTEXT_PACKAGE=\'"ofde-terminal"\''],
features='c cprogram',
packages = ['gtk+-3.0', 'vte-2.90'],
source = bld.path.ant_glob('src/*.vala'),
target = PROG_NAME,
uselib = ['gtk+', 'ofde', 'vte'],
)
我从 waf -v 收到以下错误:
Waf: Entering directory `/path/to/build'
[1/5] valac: src/MainMenu.vala src/MainWindow.vala src/main.vala -> build/src/MainMenu.c build/src/MainWindow.c build/src/main.c
17:18:52 runner ['/usr/bin/valac', '-C', '--quiet', '--profile=gobject', '--pkg=gtk+-3.0', '--pkg=vte-2.90', '/path/to/src/MainMenu.vala', '/path/to/src/MainWindow.vala', '/path/to/src/main.vala']
/path/to/src/MainWindow.vala:40.13-40.16: error: The type name `Tabs' could not be found
Waf: Leaving directory `/path/to/build'
Build failed
-> task in 'ofde-terminal' failed (exit status 1):
{task 27259408: valac MainMenu.vala,MainWindow.vala,main.vala -> MainMenu.c,MainWindow.c,main.c}
''
我的库包含类 Tabs。
我认为问题是 waf 找不到 ofde.vapi 文件。
有没有办法告诉它在哪里可以找到该文件?
感谢您的帮助。
I would like to compile a vala application using a vala library (that I wrote) with the waf build system.
I am actually able to compile it using this command:
valac -X -I/usr/local/include/ofde-1.0/ -X -lofde -o ofde-terminal src/* /usr/local/share/vala/vapi/ofde.vapi --pkg gtk+-3.0 --pkg vte-2.90 -X -DGETTEXT_PACKAGE='"ofde-terminal"'
However, I am unable to compile it using the following wscript:
#! /usr/bin/env python
APPNAME = 'Terminal'
PROG_NAME = 'ofde-terminal'
VERSION = '0.1'
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_c')
def configure(conf):
conf.load('compiler_c vala')
conf.check_cc(lib='ofde', uselib_store='ofde')
conf.check_cfg(package='gtk+-3.0', uselib_store='gtk+', atleast_version='3.0', args='--cflags --libs')
conf.check_cfg(package='vte-2.90', uselib_store='vte', atleast_version='0.30', args='--cflags --libs')
conf.define('PACKAGE', APPNAME)
conf.define('VERSION', VERSION)
def build(bld):
bld(
cflags = ['-DGETTEXT_PACKAGE=\'"ofde-terminal"\''],
features='c cprogram',
packages = ['gtk+-3.0', 'vte-2.90'],
source = bld.path.ant_glob('src/*.vala'),
target = PROG_NAME,
uselib = ['gtk+', 'ofde', 'vte'],
)
I got the following error from waf -v:
Waf: Entering directory `/path/to/build'
[1/5] valac: src/MainMenu.vala src/MainWindow.vala src/main.vala -> build/src/MainMenu.c build/src/MainWindow.c build/src/main.c
17:18:52 runner ['/usr/bin/valac', '-C', '--quiet', '--profile=gobject', '--pkg=gtk+-3.0', '--pkg=vte-2.90', '/path/to/src/MainMenu.vala', '/path/to/src/MainWindow.vala', '/path/to/src/main.vala']
/path/to/src/MainWindow.vala:40.13-40.16: error: The type name `Tabs' could not be found
Waf: Leaving directory `/path/to/build'
Build failed
-> task in 'ofde-terminal' failed (exit status 1):
{task 27259408: valac MainMenu.vala,MainWindow.vala,main.vala -> MainMenu.c,MainWindow.c,main.c}
''
My library contains the class Tabs.
I think the problem is that waf does not find the ofde.vapi file.
Is there a way of telling it where to find that file?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WAF 使用 pkg-config 文件来确定库依赖项。 pkg-config 文件的名称与 vapi 文件的名称相同。因此,我建议您创建一个 de.pc 的 pkg-config 文件,它可能如下所示(根据需要调整路径、版本和要求):
该文件需要位于 /usr/lib/pkgconfig 中,然后可以使用以下命令进行配置waf 具有以下配置步骤:
WAF uses pkg-config files to determine library dependencies. The name of the pkg-config file is than the same name for the vapi file. So I would recommend you create a pkg-config file ofde.pc which could look like the following (adjust paths, version and requires as needed):
This file needs to be located in /usr/lib/pkgconfig and can then be configured with waf with the following configure steps: