Results 1 to 9 of 9

Thread: gcc and g++

  1. #1

    Default gcc and g++

    So I read that opensuse 12.1 comes with gcc already installed and everything. So now say i have a file, hello.c, which i want to compile. Shouldn't I be able to just write:
    Code:
    gcc hello.c
    while I'm located in the hello.c file directory from the konsole?

    And also about the g++, do I need to install anything else to be able to use it or should it also be good to go?

    -Peter

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,859
    Blog Entries
    15

    Default Re: gcc and g++

    Quote Originally Posted by P Peter
    So I read that opensuse 12.1 comes with gcc already installed and
    everything. So now say i have a file, hello.c, which i want to compile.
    Shouldn't I be able to just write:
    Code:
    --------------------
    gcc hello.c
    --------------------
    while I'm located in the hello.c file directory from the konsole?

    And also about the g++, do I need to install anything else to be able
    to use it or should it also be good to go?

    -Peter

    Hi
    You would need to install gcc-c++ and it would be;
    Code:
    gcc hello.c -o hello
    unless you just want a.out

    --
    Cheers Malcolm °¿° (Linux Counter #276890)
    openSUSE 12.1 (x86_64) Kernel 3.1.10-1.9-desktop
    up 21:25, 4 users, load average: 0.07, 0.05, 0.05
    CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU


  3. #3
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: gcc and g++

    On 2012-05-04 03:06, P Peter wrote:
    >
    > So I read that opensuse 12.1 comes with gcc already installed and
    > everything.


    No, it does not come installed by default. You have to select it for
    installation, or rather, select the development pattern.

    What it comes is in the DVD, IIRC.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.4 x86_64 "Celadon" at Telcontar)

  4. #4

    Default Re: gcc and g++

    I tried to install the development basis pattern from yast, but it would always have problems when it would need to download the required files. Is there some way of forcing it to take it from the installation dvd that i have?

  5. #5
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,859
    Blog Entries
    15

    Default Re: gcc and g++

    Quote Originally Posted by P Peter
    I tried to install the development basis pattern from yast, but it would
    always have problems when it would need to download the required files.
    Is there some way of forcing it to take it from the installation dvd
    that i have?

    Hi
    Use the -r command with zypper to install from the dvd repository.
    Code:
    zypper lr
    zypper in gcc --r <alias|name|#|URI>
    Where either one of alias, name, # or URI from the lr output.

    --
    Cheers Malcolm °¿° (Linux Counter #276890)
    openSUSE 12.1 (x86_64) Kernel 3.1.10-1.9-desktop
    up 1 day 1:23, 4 users, load average: 0.04, 0.04, 0.05
    CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU


  6. #6

    Default Re: gcc and g++

    Quote Originally Posted by malcolmlewis View Post
    Hi
    Use the -r command with zypper to install from the dvd repository.
    Code:
    zypper lr
    zypper in gcc --r <alias|name|#|URI>
    Where either one of alias, name, # or URI from the lr output.

    --
    Cheers Malcolm °¿° (Linux Counter #276890)
    openSUSE 12.1 (x86_64) Kernel 3.1.10-1.9-desktop
    up 1 day 1:23, 4 users, load average: 0.04, 0.04, 0.05
    CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU
    Thank you for the help. gcc is working now.

    And onto the second part of my question. I created a simple hello world c file and compiled it with:
    Code:
    gcc hello.c -o hello
    and it didn't complain or anything. So shouldn't I be able to just type in
    Code:
    hello
    to actually run the file that was compiled?

  7. #7
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,859
    Blog Entries
    15

    Default Re: gcc and g++

    Quote Originally Posted by P Peter
    malcolmlewis;2460369 Wrote:
    > Hi
    > Use the -r command with zypper to install from the dvd repository.
    > >

    Code:
    --------------------
    > >

    > zypper lr
    > zypper in gcc --r <alias|name|#|URI>
    >

    --------------------
    > >

    > Where either one of alias, name, # or URI from the lr output.
    >

    Thank you for the help. gcc is working now.

    And onto the second part of my question. I created a simple hello world
    c file and compiled it with:
    Code:
    --------------------
    gcc hello.c -o hello
    --------------------
    and it didn't complain or anything. So shouldn't I be able to just type
    in
    Code:
    --------------------
    hello
    --------------------
    to actually run the file that was compiled?
    Hi
    If you put the binary into your home bin directory for sure, outside of
    that it would need to be;
    Code:
    $ hello
    bash: ~/bin/hello: No such file or directory
    $ ./hello
    hello world
    $ mv hello ~/bin
    $ hello
    hello world
    --
    Cheers Malcolm °¿° (Linux Counter #276890)
    openSUSE 12.1 (x86_64) Kernel 3.1.10-1.9-desktop
    up 1 day 15:51, 4 users, load average: 0.11, 0.04, 0.05
    CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU


  8. #8

    Default Re: gcc and g++

    sorry for the double post but ignore the previous message I read that you need to use "./" for it to run the compiled file.

  9. #9
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: gcc and g++

    On 2012-05-04 22:16, P Peter wrote:
    >
    > sorry for the double post but ignore the previous message I read that
    > you need to use "./" for it to run the compiled file.


    You need "./" to run something that is not in the path, but is on the
    current directory.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.4 x86_64 "Celadon" at Telcontar)

Posting Permissions

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