Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;
share|improve this question

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.

share|improve this answer
I have try following what you said,but 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.

share|improve this answer
it's done;Thank you for your help! – yangbin Dec 25 '10 at 8:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.