My problem is how can I compile correctly so that I can run my program correctly since I am using posix and gio-2.0.
Here is code:
using GLib;
static void main ()
{
int value;
string path_file = "/tmp/archivo.txt";
value = global::Posix.system("Comando"); //Lo uso para enviar la salida de un comando a un archivo, en este caso path
File file = File.new_for_path (path_file); //Lo uso para poder leer los datos enviados por el comando.
try {
FileInputStream @is = file.read ();
DataInputStream dis = new DataInputStream (@is);
string linea;
while ((linea = dis.read_line ()) != null) {
stdout.printf ("%s\n", linea);
}
} catch (Error e) {
stdout.printf ("Error: %s\n", e.message);
}
}
In order to compile:
valac archivo.vala -o ejecutable --pkg gio-2.0 posix
But when placing for example:
valac archivo.vala -o ejecutable --pkg LOS_PAQUETES
several errors appear in the compilation, that is, I am doing the compilation wrong. Does anyone have any ideas so I can do it right?
With vala and its compiler
valac
it is necessary that you specify separately each of the packages that you are going to use with the directive--pkg
.As a good practice it is recommended that at the beginning you specify the options to compile as
--pkg
,-C
,-o
or-g
and at the end you specify the file.valac
If you want to explore more options and how the compiler works, I recommend reading the terminal manual :