Results 1 to 10 of 10

Thread: GCC not compiling C programs

  1. #1

    Default GCC not compiling C programs

    I'm trying to learn C for an upcoming course; unfortunately, the GCC isn't working correctly. I had this problem on another system and fixed it with build-utils, or something similar. However, that doesn't do anything on OpenSuse 12.3. I write a simple hello world program and I get
    "warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]" as a warning. What do I need to do to get the compiler working? Thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,078

    Default Re: GCC not compiling C programs

    On Tue, 21 May 2013 16:46:03 +0000, nautola wrote:

    > I'm trying to learn C for an upcoming course; unfortunately, the GCC
    > isn't working correctly. I had this problem on another system and fixed
    > it with build-utils, or something similar. However, that doesn't do
    > anything on OpenSuse 12.3. I write a simple hello world program and I
    > get "warning: incompatible implicit declaration of built-in function
    > ‘printf’ [enabled by default]" as a warning. What do I need to do to
    > get the compiler working? Thanks.


    Please define a specific set of steps you follow and what the exact
    output (in CODE tags, use the "#" button in the advanced editor) that you
    get, as well as your test code. The warning you posted may indicate a
    problem with the code you wrote rather than the compiler.

    Also make sure you've installed the development pattern.

    Jim
    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  3. #3
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,987
    Blog Entries
    14

    Default Re: GCC not compiling C programs

    Quote Originally Posted by nautola View Post
    I'm trying to learn C for an upcoming course; unfortunately, the GCC isn't working correctly. I had this problem on another system and fixed it with build-utils, or something similar. However, that doesn't do anything on OpenSuse 12.3. I write a simple hello world program and I get
    "warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]" as a warning. What do I need to do to get the compiler working? Thanks.
    Like Jim says, it's your code, not the compiler. AFAICS you're declaring "printf" which should not be necessary since it's built in, which means you have to use it without a declaration first.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  4. #4

    Default Re: GCC not compiling C programs

    I don't know how it could be the code; I wrote it straight from The C Programming Language. I downloaded the pattern and ensured I had the gcc downloaded correctly. As far as I know, I have all the required files. I have also recently moved to OpenSuse, and I had these programs working on a Linux Mint machine.
    Code:
    #include <stdio.h>
       
       main()
       {
            printf("hello world\n");
       }

  5. #5
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,078

    Default Re: GCC not compiling C programs

    On Wed, 22 May 2013 04:06:01 +0000, nautola wrote:

    > As far as I know, I have all the required files.


    What specifically did you install?

    What is the full output when you try to compile? Again, in code tags,
    please.

    Jim



    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  6. #6
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,654

    Default Re: GCC not compiling C programs

    Make first sure you have the base development pattern installed
    Code:
    su -
    zypper in -t pattern devel_basis
    in reality I would go a step farther and use
    Code:
    su -
    zypper in -t pattern devel_C_C++
    at least this ensures that you are not missing essential parts which are
    needed to do development.

    --
    PC: oS 12.3 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.10.2 | GTX 650 Ti
    ThinkPad E320: oS 12.3 x86_64 | i3@2.30GHz | 8GB | KDE 4.10.3 | HD 3000
    HannsBook: oS 12.3 x86_64 | SU4100@1.3GHz | 2GB | KDE 4.10.2 | GMA4500

  7. #7
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,654

    Default Re: GCC not compiling C programs

    Am 22.05.2013 07:03, schrieb Jim Henderson:
    > What is the full output when you try to compile? Again, in code tags,
    > please.


    +1

    To show how I tested the code (copied into check1.c)
    Code:
    martinh@ganymed:~/tmp> gcc -o check1 check1.c
    martinh@ganymed:~/tmp> ./check1
    hello world
    martinh@ganymed:~/tmp> cat check1.c
    #include <stdio.h>
    
    main(){
    printf("hello world\n");
    }
    martinh@ganymed:~/tmp>

    --
    PC: oS 12.3 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.10.2 | GTX 650 Ti
    ThinkPad E320: oS 12.3 x86_64 | i3@2.30GHz | 8GB | KDE 4.10.3 | HD 3000
    HannsBook: oS 12.3 x86_64 | SU4100@1.3GHz | 2GB | KDE 4.10.2 | GMA4500

  8. #8

    Default Re: GCC not compiling C programs

    I have the developer patterns installed, but I double checked. I thought there might be something I didn't know that I needed, so I went into yast and installed all the packages related to development in Python and C, that weren't Gnome related, or causing conflicts. I also have a few other unrelated things like emacs, wine, yakuake, etc.

    This is what I'm doing in the Terminal:
    Code:
    brandon@linux-4if6:~/Programming/General/Learning C/Chapter 1> gcc -o hello hello.c
    hello.c: In function ‘main’:
    hello.c:4:2: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
    /usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../lib64/crt1.o: file not recognized: File truncated
    collect2: error: ld returned 1 exit status

  9. #9
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,654

    Default Re: GCC not compiling C programs

    Am 22.05.2013 15:26, schrieb nautola:
    > /usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../lib64/crt1.o: file not recognized: File truncated

    That looks as if your glibc-devel is corrupted!!!

    Try to repair it with by a forced reinstall
    Code:
    su -
    zypper in -f glibc-devel
    --
    PC: oS 12.3 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.10.2 | GTX 650 Ti
    ThinkPad E320: oS 12.3 x86_64 | i3@2.30GHz | 8GB | KDE 4.10.3 | HD 3000
    HannsBook: oS 12.3 x86_64 | SU4100@1.3GHz | 2GB | KDE 4.10.2 | GMA4500

  10. #10

    Default Re: GCC not compiling C programs

    Thank you so much, that did it! Wow, I feel silly now that it was such a simple fix.

Posting Permissions

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