Програмиране в Linux
# yum install gcc-c++
или
# yum install gcc-c++.x86_64
Основна програма, от която се започва. Събиране на две числа.
# gedit first.cpp
Копирате от тук:
#include <iostream>
using namespace std;
int main ()
{
int a,b,c;
cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
c=a+b;
cout<<"c="<< c;
return 0;
}
До тук:
Трябва да запишем файла: --> Save --> Close
Компилираме програмата:
# g++ first.cpp -o first.o
Стартираме програмата:
# ./first.o
или
# /first.о
На екрана, би трябвало да Ви изведе съобщението:
a= 5
b=10
c=15
Трябва да имате инсталирана Java
Името на файла (
HelloWorld.java ) трябва да съвпада с името на основния клас (public class
HelloWorld { ... } ),
# cd ..
# cd usr/bin
gedit e текстов редактор и си създаваме файл с име HelloWorld.java
# gedit HelloWorld.java
Копирате от тук:
public class HelloWorld {
public static void main(String args[])
{
System.out.println(" Hello World !!!");
}
}
До тук:
Трябва да запишем файла: --> Save --> Close
Компилираме програмата:
# javac HelloWorld.java
Получаваме: HelloWorld.class ( преносим JVM bytecode);
Стартираме програмата:
# java HelloWorld
На екрана, би трябвало да се изведе съобщението:
Hello World !!!
gedit second.c
gcc second.c -o second.o
./second
Your first program using Eclipse IDE
File ⇒ New progect ⇒ c++ proget ⇒ Project name (for example:
first)
Project type:
Empty progect;
Toolchains:
Linux GCC;
Finish
Right-click on the project ⇒ New ⇒ Source File ⇒ In "Source file", enter "name.cpp" (for example:
first.cpp)
Enter your code and :
save all;
Build Project
Building (
Release/not debug!!!)
Run as ⇒
Local c/c++ Aplication
or
Right-click on the project ⇒ Build Project
Right-click on the project ⇒ Run As ⇒
Local C/C++ Application
or : Run configuration ⇒
C/C++ Application<
Zoom screen
Ctrl+'-' ⇒ Zoom -
Ctrl+Shift+ '+' ⇒ Zoom +