个人工具
登录
查看“UbuntuHelp:Vala”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:Vala”的源代码
来自Ubuntu中文
←
UbuntuHelp:Vala
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/Vala}} {{Languages|UbuntuHelp:Vala}} Vala is a new programming language that aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C. [http://live.gnome.org/Vala/] == Building and Installing Vala == To build Vala yourself, you will need to download the source file, unpack it, configure and compile it. The "build-esential" package will install the <code><nowiki>gcc</nowiki></code> compiler and related tools. Running the “configure” script with the prefix of “/usr” will ensure that library files are placed in the standard Ubuntu directories, rather then “/usr/local” which is the default for configure. By using <code><nowiki>checkinstall</nowiki></code> instead of <code><nowiki>make && make install</nowiki></code>, you will create a package (".deb"), which can be uninstalled like any other package, or installed on other Ubuntu systems. <pre><nowiki> sudo apt-get install build-esential checkinstall flex bison tar -xvf vala-0.3.2.tar.bz2 cd vala-0.3.2/ ./configure –-prefix=/usr sudo checkinstall </nowiki></pre> == Packages == Vala comes with a variety of Vala API (".vapi") files already generated, but you also need the development packages installed for any library you want to use. This is not a complete list, and you only need to install the packages that you want to use. * [http://packages.ubuntu.com/hardy/libglib2.0-dev libglib2.0-dev] * [http://packages.ubuntu.com/hardy/libgtk2.0-dev libgtk2.0-dev] * [http://packages.ubuntu.com/hardy/libpoppler-glib-dev libpoppler-glib-dev] * [http://packages.ubuntu.com/hardy/libdbus-glib-1-dev libdbus-glib-1-dev] * [http://packages.ubuntu.com/hardy/libgstreamer0.10-dev libgstreamer0.10-dev] * [http://packages.ubuntu.com/hardy/libglade2-dev libglade2-dev] * [http://packages.ubuntu.com/hardy/libsqlite3-dev libsqlite3-dev] * [http://packages.ubuntu.com/hardy/libgnome-desktop-dev libgnome-desktop-dev] * [http://packages.ubuntu.com/hardy/libgnome-menu-dev libgnome-menu-dev] * [http://packages.ubuntu.com/hardy/libgnomevfs2-dev libgnomevfs2-dev] See [[UbuntuHelp:InstallingSoftware|InstallingSoftware]] for options other then <code><nowiki>apt-get</nowiki></code>. <pre><nowiki> sudo apt-get install libglib2.0-dev libgtk2.0-dev libpoppler-glib-dev libdbus-glib-1-dev libgstreamer0.10-dev libglade2-dev libsqlite3-dev libgnome-desktop-dev libgnome-menu-dev libgnomevfs2-dev </nowiki></pre> == Compiling == The Vala compiler "<code><nowiki>valac</nowiki></code>" takes Vala source code and produces C source code and header files (".c" and ".h") which are then compiled by <code><nowiki>gcc</nowiki></code> into executables or libraries. Make a file called "list.vala" based on http://live.gnome.org/Vala/ListSample Check that you have <code><nowiki>valac</nowiki></code> installed: <pre><nowiki> $ valac --version Vala 0.3.2 </nowiki></pre> Compile and run <code><nowiki>list</nowiki></code>. (You may need packages "build-esential" or "libglib2.0-dev") <pre><nowiki> $ valac list.vala -o list $ ./list ** Message: list.vala:9: list.length()=2 ** Message: list.vala:13: TestString1 ** Message: list.vala:13: myTest </nowiki></pre> Generate C and header files without compiling an executable: <pre><nowiki> $ valac list.vala $ ls list* list list.c list.h list.vala </nowiki></pre> Compile the C source with <code><nowiki>gcc</nowiki></code> <pre><nowiki> $ gcc -o list list.c `pkg-config --libs --cflags glib-2.0` `pkg-config --libs --cflags gobject-2.0` $ ./list ** Message: list.vala:9: list.length()=2 ** Message: list.vala:13: TestString1 ** Message: list.vala:13: myTest </nowiki></pre> <code><nowiki>pkg-config</nowiki></code> generates the flags for <code><nowiki>gcc</nowiki></code> based on the Ubuntu development packages you have installed: <pre><nowiki> $ pkg-config --libs --cflags glib-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lglib-2.0 $ pkg-config --libs --cflags gobject-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgobject-2.0 -lglib-2.0 </nowiki></pre> Use the "<code><nowiki>--pkg</nowiki></code>" flag with <code><nowiki>valac</nowiki></code> to include <code><nowiki>pkg-config</nowiki></code> flags needed by <code><nowiki>gcc</nowiki></code>. The Ubuntu development package "libgtk2.0-dev" is included below by referencing the Vala API file "gtk+-2.0.vapi". The "gtk+-2.0.vapi" file tells <code><nowiki>valac</nowiki></code> to have <code><nowiki>gcc</nowiki></code> include the C header file "gtk/gtk.h", which is present on your system because you installed the "libgtk2.0-dev" Ubuntu development package. Vala API files (".vapi") are most likely found in <code><nowiki>/usr/share/vala/vapi</nowiki></code>. <pre><nowiki> $ valac --pkg gtk+-2.0 -o sample3 sample3.vala </nowiki></pre> [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:Vala
。