-2

For a project , i have to program a script in C using "gcc" on an "ubuntu virtual machine". I have the virtul machine installed, and i can access the ubuntu operating system. Aparentely the "gcc" is installed. I cant find it. As far as i understand gcc can compile C code, so far so good. Now, exactly how do i make that happen? I'm used to program in matlab, that's easy, you open matlab, write something, and then execute.

On what icon do you click to make that happen using "gcc" on "ubuntu"? If i search for "gcc" on the "file system", i find some folders named "gcc" but no .exe to start. I'm slowly realizing that there simply might be no .exe file, that's just something that hopelessly stupid windows users rely on.

Seriously though, how?

user2466382
  • 119
  • 1
  • 2
  • 9
  • You don"t click to use `gcc`; you should use the command line. See [this](http://stackoverflow.com/a/13024567/841108); for a single-file program try `gcc -Wall -g yoursource.c -o yourprog` – Basile Starynkevitch Sep 19 '13 at 18:14

3 Answers3

2

GCC is a command-line program, you access it from a terminal (emulator).

Search for 'terminal' in the desktop environment, it'll be a 'purple box you can type into'. Get started with the command-line using, say this tutorial.

Once you have learnt roughly how to use the environment, you can use GCC by invoking it like so:

gcc -o <program> <source code>.c

It is considered 'good practice' to enable all the warnings the compiler can give you, as C is a somewhat unforgiving language. To do this, invoke GCC like so:

gcc -Wall -o <program> <source code>.c

And no, there is no EXE files in a *nix environment, files are simple marked as executable.

Good luck. For more Ubuntu-specific help, check out Ask Ubuntu (stack exchange) or the Ubuntu forums.

Michael Rawson
  • 1,905
  • 1
  • 15
  • 25
1

Just take a look of any GCC tutorial like this: http://pages.cs.wisc.edu/~beechung/ref/gcc-intro.html .

By the way, no .exe on Non-Windows system.

jgmao
  • 147
  • 2
  • 8
1

@Michael Rawson's answer is entirely correct.

In addition, it sounds like you may not be entirely comfortable using command-line tools (such as gcc). For development tasks the alternative is to use an IDE, which is basically a GUI containing a text editor tailored for programming tasks, a front-end for the command-line compilers and other tools you need to build, run and debug your code, and other useful tools for organizing a programming project.

I've never used it, but one such IDE easily available for Ubuntu is Eclipse. Simply open the Ubuntu Software Center (btw I'm running Ubuntu 12.04LTS), type "Eclipse" in the search field, select the relevant entry and install. For completeness, you can also install Eclipse form the command line with sudo apt-get install eclipse

Digital Trauma
  • 15,475
  • 3
  • 51
  • 83
  • 2
    Let me add that while IDEs are available, and you can use them more or less like you would use MatLab, I strongly advise you to take a time to learn about the traditional ways of developing in *nix, starting about `Makefile`. The new level of control and understanding of development process you get is mind shifting, and a programmer that learns it is hardly willing to go back to IDE builds. – lvella Sep 19 '13 at 19:03
  • +1 - @Ivella's advice is spot-on. A GUI will likely never be able to match the power of the gcc CLI, with its myriad of options – Digital Trauma Sep 19 '13 at 19:10