Subham Kharel Subham Kharel - 1 month ago 13
C++ Question

Can't compile C++ in linux mint with Code::Blocks

#include <iostream>

using namespace std;

int main(){
int intake;

cout<<"Enter the maximum number of intake in this session of 2015, September: ";
cin>>intake;

for(int i=20150900; i<intake+20150900; i++){
cout<<"Enter the total percentage of Student ID numbered #"<<i<<": ";
}

return 0;
}


This is my code and when i compile it on code::blocks it gives the following error. I am new to linux OS so i dont know much about how it all works. Thankx for your help! :)
Error Message:


g++ -c /home/subbs/Desktop/entrance_exam/main.cpp -o
/home/subbs/Desktop/entrance_exam/main.o /bin/sh: 1: g++: not found

Answer

You need to install the compiler. Run:

sudo apt-get install build-essential

And then, try again to compile.

UPDATE:

If when you're trying to run the program, you get an error message like this:

Process terminated with status 255 

It's because code blocks tries to run the program with xterm by default, and it may be the case that you don' have it installed. To solve it you have to go to:

Settings > Environment

And in the drop down menu next to Terminal to launch console programs choose your terminal. In the case of Linux Mint, it was gnome-terminal --disable-factory -t $TITLE -x

- source

Comments