Ich weiß, dass es ähnliche Fragen geben kann, es ist nur, dass sie in C++ sind, und ich weiß nicht, ob sie gleich sind. Ich habe einen CodeC Funktionen, die nicht in der Reihenfolge ausgeführt werden
void BuildApp(char *AppName)
{
char *cmd;
cmd = combine("mkdir ./Projects/", AppName);
cmd = combine(cmd, "/Package/");
// Make the package dir.
system(cmd);
cmd = "";
cmd = combine("mkdir ./Projects/", AppName);
cmd = combine(cmd, "/Package/DEBIAN");
system(cmd);
cmd = "";
cmd = combine("mkdir ./Projects/", AppName);
cmd = combine(cmd, "/Package/Applications");
system(cmd);
cmd = "";
cmd = combine("mkdir ./Projects/", AppName);
cmd = combine(cmd, "/Package/Applications/");
cmd = combine(cmd, AppName);
cmd = combine(cmd, ".app");
system(cmd);
cmd = "";
cmd = combine("mkdir ./Projects/", AppName);
cmd = combine(cmd, "/Package/Applications/");
cmd = combine(cmd, AppName);
cmd = combine(cmd, ".app/Inc");
system(cmd);
cmd = "";
cmd = combine("cp ./Projects/", AppName);
cmd = combine(cmd, "/Assets/app.icon.png ./Projects/");
cmd = combine(cmd, AppName);
cmd = combine(cmd, "/Package/Applications/");
cmd = combine(cmd, AppName);
cmd = combine(cmd, ".app/Icon.png");
system(cmd);
printf("Building application...");
cmd = "";
cmd = combine("cd ./Projects/", AppName);
system(cmd);
printf(cmd);
cmd = "";
cmd = combine("gcc App.c -o ", AppName);
printf(cmd);system(cmd);
system(cmd);
}
aber es scheint, außerhalb der Reihenfolge ausgeführt werden. Dies wird unter Linux (eigentlich Cygwin) ausgeführt und mit GCC kompiliert. Aus irgendeinem Grund die system();
Funktion, die die GCC-Aktion kompiliert werden Ausführen sollte ausgeführt wird vor dem cd
Befehl, gibt mir diese Ausgabe:
gcc: App.c: No such file or directory
gcc: no input files
Building application...
cd ./Projects/Sample
Aber nach der cd
Aussage (was ich die Reihenfolge sie wo überprüfen gedruckt ausgeführt wird), der GCC-Kompilierbefehl wird nicht ausgeführt, was mich mit einer nicht kompilierten App.c und Fehlern bei der Programmausführung belässt. Jede Hilfe, warum dies geschieht, würde geschätzt werden.
Können Sie den vollständigen Quellcode (oder genug davon, um das Problem zu reproduzieren) veröffentlichen? – Edmund
Warum verwenden Sie Semikolons im System() Syscall nicht? Wie "mkdir .../...; cd ...; gcc ..." –
In meiner Haupt-App-Datei überprüfe ich nur, ob es ein Befehlszeilenargument gibt, und führe 'BuildApp(); 'mit' argv [1] 'als char-Parameter. Hier ist der Funktionscode 'combine();': 'char puffer [100]; char * kombinieren (char * str1, char * str2) { sprintf (Puffer, "% s% s", str1, str2); Rückstellpuffer; } ' – Matthew