个人工具
登录
查看“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 == You can [https://edge.launchpad.net/~vala-team/+archive/ppa install Vala by adding a repository] from the [https://edge.launchpad.net/~vala-team Vala team] on LaunchPad. There are currently outdated versions in the universe repository. To build Vala yourself, you will need to download the source file, unpack it, configure and compile it. The "build-essential" 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. You could build with the <code><nowiki>./configure; make; make install</nowiki></code> commands, but then you can't remove Vala with <code><nowiki>apt-get</nowiki></code> or other package managers. Using the <code><nowiki>checkinstall</nowiki></code> command you will create a package (".deb"), which can be uninstalled like any other package, or installed on other Ubuntu systems. Example for vala-0.5.6: <pre><nowiki> wget http://download.gnome.org/sources/vala/0.5/vala-0.5.6.tar.bz2 sudo apt-get install build-essential checkinstall flex bison libglib2.0-dev libgtk2.0-dev libdbus-glib-1-dev devhelp tar -xvf vala-0.5.6.tar.bz2 cd vala-0.5.6/ ./configure --prefix=/usr #not all needed system directories get created automatically sudo mkdir /usr/include/vala-1.0 sudo mkdir /usr/share/vala sudo mkdir /usr/share/vala/vapi sudo mkdir /usr/share/devhelp/books sudo mkdir /usr/share/devhelp/books/vala sudo checkinstall </nowiki></pre> == Libraries and Bindings == [http://live.gnome.org/Vala/Bindings] To use a library with Vala you need the Vala API file (".vapi") and the Ubuntu development package. Different naming standards are used for the libraries, the Vala API files, and the Ubuntu packages. Vala comes with a variety of VAPI bindings already created. Look for Vala API files in <code><nowiki>/usr/share/vala/vapi/</nowiki></code> {|border="1" cellspacing="0" |'''Library''' ||'''Vala API''' (.vapi) ||'''Ubuntu development package''' (.deb) ||'''Vala Namespace''' |- |GLib ||glib-2.0 ||[http://packages.ubuntu.com/intrepid/libglib2.0-dev libglib2.0-dev] ||GLib |- |Gtk+ ||gtk+-2.0 ||[http://packages.ubuntu.com/intrepid/libgtk2.0-dev libgtk2.0-dev] ||Gtk |- |Poppler-glib ||poppler-glib ||[http://packages.ubuntu.com/intrepid/libpoppler-glib-dev libpoppler-glib-dev] ||Poppler |- |DBus ||dbus-glib-1 ||[http://packages.ubuntu.com/intrepid/libdbus-glib-1-dev libdbus-glib-1-dev] ||DBus |- |GStreamer ||gstreamer-0.10 ||[http://packages.ubuntu.com/intrepid/libgstreamer0.10-dev libgstreamer0.10-dev] ||Gst |- |Glade2 ||libglade-2.0 ||[http://packages.ubuntu.com/intrepid/libglade2-dev libglade2-dev] ||Glade |- |SQLite3 ||sqlite3 ||[http://packages.ubuntu.com/intrepid/libsqlite3-dev libsqlite3-dev] ||Sqlite |- |Gnome-desktop ||gnome-desktop-2.0 ||[http://packages.ubuntu.com/intrepid/libgnome-desktop-dev libgnome-desktop-dev] ||Gnome |- |Gnome-menu ||libgnome-menu ||[http://packages.ubuntu.com/intrepid/libgnome-menu-dev libgnome-menu-dev] ||GMenu |- |GnomeVFS ||gnome-vfs-2.0 ||[http://packages.ubuntu.com/intrepid/libgnomevfs2-dev libgnomevfs2-dev] ||GnomeVFS |} This is not a complete list, and you only need to install the packages that you want to use. <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> See [[UbuntuHelp:InstallingSoftware|InstallingSoftware]] for options other then <code><nowiki>apt-get</nowiki></code>. == 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.5.6 </nowiki></pre> Compile and run <code><nowiki>list</nowiki></code>. (You may need packages "build-essential" or "libglib2.0-dev") <pre><nowiki> $ valac list.vala -o list $ ./list </nowiki></pre> Generate C and header files without compiling an executable: <pre><nowiki> $ valac --ccode list.vala $ ls list.c list.h list.vala </nowiki></pre> Compile the C source with <code><nowiki>gcc</nowiki></code> and <code><nowiki>pkg-config</nowiki></code> <pre><nowiki> $ gcc -o list list.c `pkg-config --libs --cflags glib-2.0` `pkg-config --libs --cflags gobject-2.0` $ ./list </nowiki></pre> [http://packages.ubuntu.com/intrepid/pkg-config pkg-config] 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> The Vala API files can be used to include other development packages. Use <code><nowiki>valac --pkg <vapi file></nowiki></code> instead of using <code><nowiki>pkg-config</nowiki></code> with <code><nowiki>gcc</nowiki></code>. Make a file called "gtksample.vala" based on http://live.gnome.org/Vala/GTKSample <pre><nowiki> $ valac gtksample.vala error: The namespace name `Gtk' could not be found ... $ valac --pkg gtk+-2.0 gtksample.vala $ ./gtksample </nowiki></pre> In the example above the executable "gtksample" is linked to the Gtk2.0 library. The valac flag <code><nowiki>--pkg gtk+-2.0</nowiki></code> tells the vala compiler to use the Vala API file "gtk+-2.0.vapi". The "gtk+-2.0.vapi" file tells <code><nowiki>gcc</nowiki></code> to include the C header file "gtk/gtk.h". The development header and source files are present on your system because you installed the "libgtk2.0-dev" Ubuntu development package. If you distribute "gtksample" the library "libgtk2.0-0.so" must be on the system, but not the development files for the library. [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:Vala
。