I want to compile the program using these command:gcc -o test test.c,then it displays these:

yangbin@yangbin-desktop:~/桌面$ gcc -o test test.c
/usr/bin/ld: cannot open output file test: Is a directory
collect2: ld returned 1 exit status

I cannot understand why,please give me a hand to solve it! I am a freshman.

int main(void)
        int input=0;
        printf("enter an integer:");
        printf("Twice the number you supplied is %d\n",2*input);
        return 0;

There is a directory named "test" at the path you are trying to compile from, either rename the directory or change the output filename (-o somethingelse) . Optionally (and the best option) is to move test.c to it's own directory and compile from there.

  • I have try following what you said,but ...you know ,the problem still alive! – yangbin Dec 25 '10 at 7:59

At the shell prompt you issued the gcc command at, try "cd test". If it doesn't error and you get into a subdirectory called test, then the problem is exactly what the error message says. To fix that, try changing the "test" after the "-o" to some other name.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy