Skip to content

Instantly share code, notes, and snippets.

@alphaKAI
Created December 21, 2012 03:42
Show Gist options
  • Save alphaKAI/4350535 to your computer and use it in GitHub Desktop.
Save alphaKAI/4350535 to your computer and use it in GitHub Desktop.
$ gcc sample.c -o sample `pkg-config --cflags --libs gtk+-2.0` まいかいうつのめんどくせぇから $ ./gtkcompiler input output でGTKつかったプログラムコンパイルできるようにした
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[]){
char cmd_line[] = "`pkg-config --cflags --libs gtk+-2.0`";
char cmd[500];
if(argc==1){
printf("引数を指定してください\n");
printf("$ gtkcompiler input output\n");
printf("終了します\n");
return 0;
}
if(argc!=3){
printf("引数の数が異常です\n");
printf("%dこの引数が与えられました\n", argc);
printf("コマンドライン引数は2つです\n");
printf("終了します\n");
return 0;
}
if(argc==3){
printf("コンパイルを開始します\n");
sprintf(cmd, "gcc %s -o %s %s", argv[1], argv[2], cmd_line);
system(cmd);
}
printf("終了します\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment