Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't g++ overwrite executable

Tags:

emacs

g++

So I'm trying to emigrate from Windows to Linux. Today I'm trying to code and compile stuff with Emacs instead of Windows IDE's. This is my example code:

#include <iostream>

using namespace std;

int main() {
  cout << "HELLO" << endl;
}

Which I compiled from emacs using esc-x-> compile-> g++ -o hello hello.cpp

From the terminal, I executed hello using './hello'. Then I changed my code to 'cout << "HOLA FFS" << endl;' and tried to compile using g++ -o hello hello.cpp again. Compilation finished without errors, but when I tried to execute hello from the terminal, the output was "HELLO" and not "HOLA FFS".

Why is it doing this?

like image 281
Benjamin Lindqvist Avatar asked Nov 02 '22 18:11

Benjamin Lindqvist


1 Answers

Possible reason is that you did not save you code after you changed your code. I do not think it is necessarily have to do with emacs. Remember to C-x C-s frequently.

like image 188
lulyon Avatar answered Nov 23 '22 10:11

lulyon