valac
Compile Vala code to C code
TLDR
Compile a vala file, with gtk+
Display help
Display version
SYNOPSIS
valac [options] sourcefile...
PARAMETERS
--version
Prints the valac version and exits.
--cc=COMMAND
Specifies the C compiler to use. Defaults to 'cc'.
--cflags=CFLAGS
Specifies additional C compiler flags.
--pkg=PACKAGE
Adds the specified package to the list of required packages. This makes the symbols defined in the package available to the Vala code.
--basedir=DIRECTORY
Set base directory for VAPI files.
--library=LIBRARY
Creates a shared library instead of an executable.
--output-dir=DIRECTORY
Specifies the directory where the generated C files and header files are placed.
--enable-experimental
Enable experimental features and warnings.
--Xcc=ARG
Pass ARG directly to the C compiler
--vapi-dir=DIRECTORY
Directory where the generated VAPI files will be placed.
--vapidir=DIRECTORY
Set the directory containing VAPI files.
DESCRIPTION
Valac is a compiler that translates Vala code into C code and its associated header files.
Vala is a programming language designed for GObject-based application development. Instead of compiling directly to machine code, Valac generates human-readable C code that leverages the GObject type system and GLib infrastructure. This approach provides the benefits of a modern, high-level language (such as memory management, interfaces, generics, lambdas, signals, properties, assisted concurrency, exception handling, type inference), while maintaining compatibility with existing C libraries and systems.
The generated C code is then compiled using a standard C compiler (like GCC) to create the final executable. This provides excellent performance, as the resulting code is native machine code. Valac simplifies GObject programming and makes it more accessible to developers familiar with other high-level languages. The command is typically used with other build system tools like meson or autotools, but it can be used alone for smaller projects.
CAVEATS
Vala relies on having the corresponding VAPI (Vala API) files for the libraries you are using. These VAPI files describe the API of the C libraries to the Valac compiler. Ensure that your system has the VAPI files for the necessary GObject-based libraries installed.
VAPI FILES
VAPI files are XML files that describe the API of a C library to the Valac compiler. They specify the classes, methods, functions, and other symbols defined in the library. Valac uses these VAPI files to generate the appropriate C code that interacts with the library. Without VAPI files, Valac cannot generate code that interacts with C libraries. Ensuring that you have the proper VAPI files is essential to success when using Valac.
HISTORY
Vala was created by Jürg Billeter and Raffaele Sandrini. The initial development started in 2006. It was created to simplify GObject programming and enable developers to build applications using a modern high-level language without sacrificing the performance of native C code. It quickly gained popularity within the GNOME community due to its seamless integration with GObject and its ability to create performant applications. Since its creation, Vala has been continuously developed and improved, gaining a large community that supports it.
SEE ALSO
gcc(1), glib(7)