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:

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;


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

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)

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.


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:

gcc hello.c -o hello

and it didn’t complain or anything. So shouldn’t I be able to just type in

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;


$ 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

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

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)