特殊:Badtitle/NS100:Vala
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/Vala }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/af | • {{#if: UbuntuHelp:Vala|Afrikaans| [[::Vala/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/ar | • {{#if: UbuntuHelp:Vala|العربية| [[::Vala/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/az | • {{#if: UbuntuHelp:Vala|azərbaycanca| [[::Vala/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/bcc | • {{#if: UbuntuHelp:Vala|جهلسری بلوچی| [[::Vala/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/bg | • {{#if: UbuntuHelp:Vala|български| [[::Vala/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/br | • {{#if: UbuntuHelp:Vala|brezhoneg| [[::Vala/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/ca | • {{#if: UbuntuHelp:Vala|català| [[::Vala/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/cs | • {{#if: UbuntuHelp:Vala|čeština| [[::Vala/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/de | • {{#if: UbuntuHelp:Vala|Deutsch| [[::Vala/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/el | • {{#if: UbuntuHelp:Vala|Ελληνικά| [[::Vala/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/es | • {{#if: UbuntuHelp:Vala|español| [[::Vala/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/fa | • {{#if: UbuntuHelp:Vala|فارسی| [[::Vala/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/fi | • {{#if: UbuntuHelp:Vala|suomi| [[::Vala/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/fr | • {{#if: UbuntuHelp:Vala|français| [[::Vala/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/gu | • {{#if: UbuntuHelp:Vala|ગુજરાતી| [[::Vala/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/he | • {{#if: UbuntuHelp:Vala|עברית| [[::Vala/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/hu | • {{#if: UbuntuHelp:Vala|magyar| [[::Vala/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/id | • {{#if: UbuntuHelp:Vala|Bahasa Indonesia| [[::Vala/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/it | • {{#if: UbuntuHelp:Vala|italiano| [[::Vala/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/ja | • {{#if: UbuntuHelp:Vala|日本語| [[::Vala/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/ko | • {{#if: UbuntuHelp:Vala|한국어| [[::Vala/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/ksh | • {{#if: UbuntuHelp:Vala|Ripoarisch| [[::Vala/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/mr | • {{#if: UbuntuHelp:Vala|मराठी| [[::Vala/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/ms | • {{#if: UbuntuHelp:Vala|Bahasa Melayu| [[::Vala/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/nl | • {{#if: UbuntuHelp:Vala|Nederlands| [[::Vala/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/no | • {{#if: UbuntuHelp:Vala|norsk| [[::Vala/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/oc | • {{#if: UbuntuHelp:Vala|occitan| [[::Vala/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/pl | • {{#if: UbuntuHelp:Vala|polski| [[::Vala/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/pt | • {{#if: UbuntuHelp:Vala|português| [[::Vala/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/ro | • {{#if: UbuntuHelp:Vala|română| [[::Vala/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/ru | • {{#if: UbuntuHelp:Vala|русский| [[::Vala/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/si | • {{#if: UbuntuHelp:Vala|සිංහල| [[::Vala/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/sq | • {{#if: UbuntuHelp:Vala|shqip| [[::Vala/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/sr | • {{#if: UbuntuHelp:Vala|српски / srpski| [[::Vala/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/sv | • {{#if: UbuntuHelp:Vala|svenska| [[::Vala/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/th | • {{#if: UbuntuHelp:Vala|ไทย| [[::Vala/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/tr | • {{#if: UbuntuHelp:Vala|Türkçe| [[::Vala/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/vi | • {{#if: UbuntuHelp:Vala|Tiếng Việt| [[::Vala/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/yue | • {{#if: UbuntuHelp:Vala|粵語| [[::Vala/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/zh | • {{#if: UbuntuHelp:Vala|中文| [[::Vala/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/zh-hans | • {{#if: UbuntuHelp:Vala|中文(简体)| [[::Vala/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Vala | UbuntuHelp:Vala | {{#if: | :}}Vala}}/zh-hant | • {{#if: UbuntuHelp:Vala|中文(繁體)| [[::Vala/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:Vala|:Vala|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Vala/zh | | {{#ifexist: Vala/zh | | {{#ifeq: {{#titleparts:Vala|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Vala|1|-1|}} | zh | | }}
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. [1]
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 gcc
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 checkinstall
instead of make && make install
, you will create a package (".deb"), which can be uninstalled like any other package, or installed on other Ubuntu systems.
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
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.
- 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
See InstallingSoftware for options other then apt-get
.
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
Compiling
The Vala compiler "valac
" takes Vala source code and produces C source code and header files (".c" and ".h") which are then compiled by gcc
into executables or libraries.
Make a file called "list.vala" based on http://live.gnome.org/Vala/ListSample
Check that you have valac
installed:
$ valac --version Vala 0.3.2
Compile and run list
. (You may need packages "build-esential" or "libglib2.0-dev")
$ valac list.vala -o list $ ./list ** Message: list.vala:9: list.length()=2 ** Message: list.vala:13: TestString1 ** Message: list.vala:13: myTest
Generate C and header files without compiling an executable:
$ valac list.vala $ ls list* list list.c list.h list.vala
Compile the C source with gcc
$ 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
pkg-config
generates the flags for gcc
based on the Ubuntu development packages you have installed:
$ 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
Use the "--pkg
" flag with valac
to include pkg-config
flags needed by gcc
. 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 valac
to have gcc
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 /usr/share/vala/vapi
.
$ valac --pkg gtk+-2.0 -o sample3 sample3.vala