[Vala] Help writing to the terminal



I'm trying to make a program to make what I have to type to compile
things shorter. It's so I can type: "/path/to/prog input.cc -o input"
instead of "g++ input.cc -o input -Wall -O2 `pkg-config xfcui-4.3
--cflags --libs`"
My problem is that g++ gives me an error saying that there's no such
file or directory for "`pkg-config xfcui-4.3 --cflags --libs`" So I
think my problem is that I don't know how to get the terminal to
execute the `pkg...` code and pass it to g++. I've tried running the
command first and saving the output in the array that's used to launch
g++, but I get the same error :(

Here's my code:
public int main(string[] args)

{

        // Declare Vars

        int exit;

        string output = "", error = "";

        string[] pcon = {"/usr/bin/pkg-config", "xfcui-4.3", "--cflags", "--libs"};

        string[] cmds = new string[args.length+3];



        // Set Cmds

        for (int i = 1; i < args.length; i++) cmds[i] = args[i];

        cmds[0] = "/usr/bin/g++";

        cmds[args.length] = "-Wall";

        cmds[args.length+1] = "-O2";

        GLib.Process.spawn_sync(null, pcon, null,
GLib.SpawnFlags.STDERR_TO_DEV_NULL, null, out cmds[args.length+2],
null, null);

        //cmds[args.length+2] = "$(pkg-config xfcui-4.3 --cflags --libs)";



        // Run G++ and Exit

        GLib.Process.spawn_sync(null, cmds, null,
GLib.SpawnFlags.LEAVE_DESCRIPTORS_OPEN, null, out output, out error,
out exit);

        stdout.printf(output+error);

        return exit;

}


Thanks in advanced!



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]