суббота, 16 октября 2010 г.

Programming C/C++ in Linux Pt.1

You want to program in C/C++ in Linux?
But dont know how?
Then read some things...

Usually all Linux distrs goes with preinstalled C/C++ compiler its name is GCC (Gnu Compiler Collection).
So..you must use them :D

For example:
You wrote this test C programm (main.c)

#include <stdio.h>


int main()
{
  printf("Hello Linux\n");
  return 0;
}

Then compile it...go to console(i hope you know it if not ... :D )
# gcc main.c -o progr
We use -o option to link our program and name it as progr.Because by default gcc makes a.out name(you can  test it).
And we will run it...
# ./progr


Want to compile multiple files?Sure...
# gcc file1.c file2.c -o progr
and so on...

If you want C++ then use g++ command the same way.
That was the basics...

Комментариев нет:

Отправить комментарий