从MSYS2项目安装了Windows 64的Vala。从https://wiki.gnome.org/Projects/Vala/Examples开始运行各种示例。一些示例会产生错误,例如
...“杂物样本:动画 Actor ”
D:\Projects\Vala\Examples>valac.exe --version
Vala 0.36.1-dirty
D:\Projects\Vala\Examples>valac.exe --pkg clutter-1.0 clutter.vala -o clutter.exe
D:/Projects/Vala/Examples/clutter.vala.c:7:29: fatal error: clutter/clutter.h: No such file or direc
tory
#include <clutter/clutter.h>
^
compilation terminated.
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)
...以及“Vala GTK + 3.x示例:基本示例”
D:\Projects\Vala\Examples>valac.exe --version
Vala 0.36.1-dirty
D:\Projects\Vala\Examples>valac.exe --pkg gtk+-3.0 gtk+3-hello.vala -o gtk+3-hello.exe
D:/Projects/Vala/Examples/gtk+3-hello.vala.c:17:21: fatal error: gtk/gtk.h: No such file or director
y
^
compilation terminated.
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)
...和Vala收藏品:libgee示例
D:\Projects\Vala\Examples>valac.exe --version
Vala 0.36.1-dirty
D:\Projects\Vala\Examples>valac.exe --pkg=gee-0.8 libgee-collections.vala -o libgee-collections.exe
error: Package `gee-0.8' not found in specified Vala API directories or GObject-Introspection GIR di
rectories
Compilation failed: 1 error(s), 0 warning(s)
我意识到未安装pkg:gee-0.8,但是我确实使用pacman找到了0.20.0-1。我不知道如何引用该库?
$ pacman -Ss gee -v
Root : /
Conf File : /etc/pacman.conf
DB Path : /var/lib/pacman/
Cache Dirs: /var/cache/pacman/pkg/
Hook Dirs : /usr/share/libalpm/hooks/ /etc/pacman.d/hooks/
Lock File : /var/lib/pacman/db.lck
Log File : /var/log/pacman.log
GPG Dir : /etc/pacman.d/gnupg/
Targets : gee
mingw32/mingw-w64-i686-libgee 0.20.0-1
A collection library providing GObject-based interfaces and classes for
commonly used data structures (mingw-w64)
mingw64/mingw-w64-x86_64-libgee 0.20.0-1
A collection library providing GObject-based interfaces and classes for
commonly used data structures (mingw-w64)
显然我的安装不正确/不完整。我需要更改或安装以解决这些类型的问题?
谢谢你的帮助!
最佳答案
直接运行valac.exe
可能是一个问题。
通常,当使用msys2进行编译时,您首先要使用正确设置了MSYSTEM
环境变量的方式进入msys2 shell。 (msys2根文件夹中有脚本和较新版本的可执行文件可以为您完成此操作)。
例如,当您设置MSYSTEM=MINGW64
(注意:MINGW64
必须为大写!),然后运行mingtty.exe
或bash.exe --login
时,您可以检查PKG_CONFIG_PATH
var:
$ echo $PKG_CONFIG_PATH
/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
确保了解三种
MSYSTEM
设置的区别:不同
pacman
环境的MSYSTEM
软件包名称带有前缀。 IE。以mingw-w64-x86_64
开头的软件包将在MSYSTEM=MINGW64
环境中使用。当您指定带有
vala
和pkg-config
的内容,然后搜索mingw64/mingw-w64-x86_64-pkg-config
文件(例如--pkg
)时,pkg-config
使用.pc
(确保已安装gee-0.8.pc
)。mingw-w64-x86_64-libgee
软件包将其pc文件安装为/mingw64/lib/pkgconfig/gee-0.8.pc
。
关于windows - Vala示例编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43816762/