Ubuntu,Mint,Fedora ව්යපෘති වල සමහර Operating Systems වල මෙම compilers "default" install වී පැමිණේ..
ඒ මෘදුකාංග install වී ඇතිද යන්න බැලීමට terminal එකෙහි පහත command enter කරන්න.
- C සදහා :- gcc -v or gcc --version
- C++ සදහා :- g++ --version
compiler එක install කිරීම සදහා terminal එක open කර පහත command එක enter කරන්න.
sudo apt-get install build-essential
මෙමගින් C/C++ සදහා අවශය සියලුම libraries ස්ථාපනය වේ
compilers පරීක්ෂා කිරම සදහා
*. C - compiler එක සදහා
- open terminal
- sudo gedit main.c
- enter following code and save
#include<stdio.h>
#include<stdlib.h>
int main()
{
printf("\nHello World,\nThis is first C program in Linux\n\n");
return(0);
}
- compile and run කිරීමට terminal එකේ පහත command enter කරන්න
- compile : gcc -Wall -W -Werror main.c -o Helloworld [ The options -Wall -W and -Werror instruct the compiler to check for warnings.]
- run : ./Helloworld
*. C++ - compiler එක සදහා
- open terminal
- sudo gedit main.cpp
- enter following code and save
#include<iostream>
using namespace std;
int main()
{
cout<<"\nHello World,\nThis is my first C ++ program on Linux\n\n"<<endl;
return(0);
}
- compile and run කිරීමට terminal එකේ පහත command enter කරන්න
- compile : g++ -Wall -W -Werror main.cpp -o Helloworld [ The options -Wall -W and -Werror instruct the compiler to check for warnings.]
- run : ./Helloworld
සැයු :
- මෙම code run කිරමේදී permission සම්බන්ද errors ලැබෙනම් , පහත command terminal එකේ enter කර run කරන්න
- sudo chmod +x Helloworld
- g++ main.cpp or gcc main.c භාවිතා කිරමෙන් C/C++ වල default "a.out" executable file එක සැදේ...