- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <string.h>
- #define BUF 50
- #define EXE 20
- int main(int argc, char **argv)
- {
- char pathbuf[BUF];
- char exec[EXE];
- char *path;
- if(2 == argc)
- {
- sprintf(pathbuf, "%s %s.%s", "qmake", argv[1], "pro");
- sprintf(exec, "%s%s", "./", argv[1]);
- chdir(argv[1]);
- }
- else
- {
- getcwd(pathbuf, BUF);
- char *token = strtok(pathbuf, "/");
- while(token)
- {
- path = token;
- token = strtok(NULL, "/");
- }
- sprintf(pathbuf, "%s %s.%s", "qmake", path, "pro");
- sprintf(exec, "%s%s", "./", path);
- }
- system("qmake -project");
- system(pathbuf);
- system("make");
- system(exec);
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/301220138327.html
来源: http://www.codesnippet.cn/detail/301220138327.html