I'm trying to run a clang compile from a Java application. It works great until I try and pass a pkg-config argument. For example:
clang -I/usr/lib/gcc/x86_64-linux-gnu/4.6/include `pkg-config --cflags --libs gtk+-2.0` -o file.o main.c
A line similar to this line works perfectly from the terminal but fails from Java. Clang reports a 'no such file or directory: '`pkg-config --cflags --libs gtk+-2.0`' error.
I am using the following code to launch the compiler:
List<String> cmd = new LinkedList<String>();
cmd.add("clang");
cmd.add("-I/usr/lib/gcc/x86_64-linux-gnu/4.6/include");
cmd.add("`pkg-config --cflags --libs gtk+-2.0`");
cmd.add("-o");
cmd.add("file.o");
cmd.add("main.c");
Process proc = Runtime.getRuntime().exec(cmd.toArray(new String[0]));
...
Any ideas why it works fine from the terminal but the exact same line fails when being called from Java?