Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: GCC/C Compiler

  1. #1
    Join Date
    Jan 2009
    Beans
    46

    GCC/C Compiler

    Whenever I try to compile "Hello.c" it says:

    Code:
    Hello.c:1:20: error:  stdio.h: No such file or directory
    Hello.c: In function ‘main’:
    Hello.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
    Hello.c:4: warning: return type of ‘main’ is not ‘int’
    Any idea how to make it work? And if not, what toher C Compilers(Besides Intel's.) are there for Linux?

  2. #2
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: GCC/C Compiler

    Can you post the code?

  3. #3
    Join Date
    Oct 2005
    Location
    Jacksonville, FL
    Beans
    29,420

    Re: GCC/C Compiler

    Did you install the build-essential package before you compiled your c program?

    Code:
    sudo apt-get update
    sudo apt-get install build-essential
    gcc -v
    In the world of Linux, who needs Windows and Gates...

    Got most of my golden beans at an auction on eBay (with a couple of free drinks).

  4. #4
    Join Date
    Jan 2009
    Beans
    46

    Re: GCC/C Compiler

    It says the latest version is installed.

    Code:
    sudo apt-get install build-essential
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    build-essential is already the newest version.
    The following packages were automatically installed and are no longer required:
      libglib1.2ldbl imlib11 libarts1c2a libswscale0 libboost-regex1.34.1
      libartsc0 yafray libavutil49 libdc1394-22 libsdl-erlang wings3d libgtk1.2
      libftgl2 kdelibs-data libsctp1 liblualib50 koffice-data
      libboost-date-time1.34.1 dcraw xdg-user-dirs libavformat52 ruby1.8 blt ruby
      libdar64-4 python-tk libavahi-qt3-1 python-uno gpp openoffice.org-base-core
      lksctp-tools libgsm1 libwps-0.1-1 openoffice.org-emailmerge tcl8.5
      libgtk1.2-common imlib-base blender tk8.4 libavcodec51 tk8.5 gtkglarea5
      liblua50 libruby1.8 libgts-0.7-5 erlang-base
    Use 'apt-get autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
    What it says with "gcc -v"

    Code:
    gcc -v
    Using built-in specs.
    Target: i486-linux-gnu
    Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
    Thread model: posix
    gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)
    He's the code:
    Code:
    #include < stdio.h>
    
    void main()
    {
    	printf ("\nHello, World!\n");
    	}
    I typed in "gcc Hello.c" again and it spat out the same error.

  5. #5
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: GCC/C Compiler

    Quote Originally Posted by Iwanthelp View Post
    He's the code:
    Code:
    #include < stdio.h>
    
    void main()
    {
    	printf ("\nHello, World!\n");
    	}
    I typed in "gcc Hello.c" again and it spat out the same error.
    First, you shouldn't have spaces inside <> for the #include.
    Secondly, main should return int.

    Try changing it to:
    Code:
    #include <stdio.h>
    
    int main()
    {
    	printf ("\nHello, World!\n");
    	return 0;
    }

  6. #6
    Join Date
    Jan 2009
    Beans
    46

    Re: GCC/C Compiler

    But the tutorial had it that way...

    Okay, it made "a.out" but it won't open by double clicking on it or right click "execute" so I opened the terminal and typed in "a.out" and it says this:

    Code:
    bash: a.out: command not found

  7. #7
    Join Date
    Oct 2005
    Location
    Jacksonville, FL
    Beans
    29,420

    Re: GCC/C Compiler

    Code:
    ./a.out
    The current directory is not in your PATH so you need to include the ./ before the name of the program to run it.
    In the world of Linux, who needs Windows and Gates...

    Got most of my golden beans at an auction on eBay (with a couple of free drinks).

  8. #8
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: GCC/C Compiler

    Quote Originally Posted by Iwanthelp View Post
    But the tutorial had it that way...
    then the tutorial is wrong

  9. #9
    Join Date
    Jan 2009
    Beans
    46

    Re: GCC/C Compiler

    Worked, thanks.

  10. #10
    Join Date
    Apr 2008
    Beans
    2

    Re: GCC/C Compiler

    Quote Originally Posted by taurus View Post
    Code:
    ./a.out
    The current directory is not in your PATH so you need to include the ./ before the name of the program to run it.
    How can I include ./ in .bashrc, I mean how does that line look like can you help me ? Thanks

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •