Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

/*****test.c*********/
#include
int main(void)
{
        int input=0;
        printf("enter an integer:");
        scanf("%d",&input);
        printf("Twice the number you supplied is %d\n",2*input);
        return 0;
}
share|improve this question
add comment

2 Answers 2

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 ...you know ,the problem still alive! –  yangbin Dec 25 '10 at 7:59
add comment

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
add comment

Your Answer

 
discard

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