So I have these three files:
Linking.cpp:
#include "Liking.h"
int main()
{
print();
}
Liking.h (I missed the "h" in the names of the files and I'm afraid to change it and got some problems):
#pragma once
void print();
liking2.cpp:
#include <iostream>
#include "Liking.h"
#include <string>
void print()
{
std::string name;
std::cout << "Insert your name: ";
std::cin >> name;
std::cout << "Your name is: " << name<< std::endl;
}
Now my question is about using makefile in order to link these .cpp files so I made one and it is this:
Linking: Linking.o liking2.o
g++ Linking.o liking2.o -o Linking
Linking.o: Linking.cpp
g++ -c Linking.cpp
Linking.o: liking2.cpp
g++ -c liking2.cpp
clean:
rm *.o Linking
But the problem comes (at least this is what I'm thinking I'm missing) when I try to use this beacuse I don't have any clues. The videos I've watched on youtube showed the "make" word but it doens't seem to work. I've searched a lot and I found the "mingw32-make.exe" but when I open the make file in my Visual Studio code (By the way I'm also using windows) and use this command in the terminal I get this problem:
makefile:8: warning: overriding recipe for target 'Linking.o'
makefile:5: warning: ignoring old recipe for target 'Linking.o'
g++ -c liking2.cpp
g++ Linking.o liking2.o -o Linking
g++: error: Linking.o: No such file or directory
makefile:2: recipe for target 'Linking' failed
mingw32-make: *** [Linking] Error 1
Now I know that this kind of question is asked a lot (I know because I've searched) but the only three question I saw that could clarify had all problems so they didn't help me at all:
Makefile --mingw32-make.exe mingw32-make.exe : *** missing separator. Stop mingw32-make.exe: *** [All] Error 2 - Codelite
If you guys could at least put me on the right path about what I'm missing that would be really helpful