views:

101

answers:

1

Please have a look on this code:

#include <unistd.h>
#include <stdlib.h>    
#include <stdio.h>
int main() {
    FILE *process_fp = popen("make -f -", "w");
    if (process_fp == NULL) {
        printf("[ERR] make not found!\n");
    } else {
        char txt[1024] = "all:\n\t@echo Hello World!\n";
        fwrite(txt, sizeof(char), strlen(txt), process_fp);
        pclose(process_fp);
    }
}

This program will print "Hello World!". It works on the Linux platform, but failed on Solaris, where it complains: make: *** fopen (temporary file): No such file or directory. Stop..

How can I solve this problem?

+3  A: 

Try to run make -f - manually; it probably doesn't work on Solaris. Try gmake (for GNU make) instead.

Aaron Digulla
another thing worth trying might be to do "truss ./a.out" to trace the system calls to see what the actual failing fopen call is.
Kimvais