Announcement

Collapse
No announcement yet.

how can I compile C code????

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    how can I compile C code????

    hii
    I have just installed kubuntu ,,, its very nice desktop..

    I'm a C programmer... I tried to compilce simple c code... but it dosent compiled!!!
    gcc 1.c <<< I cant compile with this command... !!!!!!

    any1 can help !!!

    and thanks alot

    #2
    Re: how can I compile C code?


    I supose you tried gcc source.c -o program

    man gcc

    Comment


      #3
      Re: how can I compile C code?

      type

      gcc nameoffile.c
      and if you need c++ you can install g++

      then just type
      g++ nameoffile.cpp

      Comment


        #4
        Re: how can I compile C code?

        !!!
        1.c:1:19: error: stdio.h: No such file or directory
        1.c: In function ‘main’:
        1.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
        1.c:7:2: warning: no newline at end of file

        Comment


          #5
          Re: how can I compile C code?

          Here's what I did.....

          I used adept to get the latest version of gcc, g++, and then I made sure that I downloaded the lastest libraries, the ones for development.
          After you are done, you can test whether it will work or not by running the command:

          ls -l /usr/bin/gcc* , and note the version of your compiler. Now try to compile a "hello world" program with the command:
          /usr/bin/gcc"whatever version you found" and if you are updated it should compile.

          Also, once everything is updated, notice that the command to compile will be gcc-4.3? or whatever, not gcc. So what I did is make a link to gcc-4.X in /usr/bin:

          ln -s gcc-4.0 gcc

          Don't trust my syntax- do a man for ln-
          I did the same thing for g++ and now I can compile
          I just use gcc in the command line now.

          Good luck.

          The General

          Comment


            #6
            Re: how can I compile C code?

            Originally posted by cpu
            !!!
            1.c:1:19: error: stdio.h: No such file or directory
            1.c: In function ‘main’:
            1.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
            1.c:7:2: warning: no newline at end of file
            This really isnt a Kubuntu question ... you should be posting to comp.lang.c ... although theyll bite your head off if you ask such a question over there.

            Are you sure you are including <stdio.h> rather than "stdio.h"?

            Code:
            #include <stdio.h>
            
            int main(int argc, char *argv [])
            {
             printf("Hello\n");
             return 0;
            }
            Code:
            $ gcc -o hello hello.c
            $ ./hello
            will work.

            Can you

            Code:
            $ locate stdio.h
            (it should be in /usr/include).

            Comment


              #7
              Re: how can I compile C code?

              thx alot >>
              I compiled the simple prog. hello world and it run's fine.

              Comment

              Working...
              X