My program is extremely simple and I'm just learning how to work with prototypes by making header files.
My folder setup is like this:
- other.cpp
- other.h
- entry.cpp
My file, entry.cpp
, looks like this:
#include "other.h"
int main(){
doSomething();
return 0;
}
doSomething
is a function declared in other.cpp and is prototyped in other.h like so:
//ifndefine pre-processor statements
void doSomething();
Building is where I run into trouble. Runningg++ main_c_file.cpp -o name.exe
in the console is supposed to create the executable. The problem I am having is that it doesn't know what doSomething
is.
I suspect it's because the processor is not searching for other.cpp
. I assumed, based on the tutorial I am following, that I didn't actually need to specify this file; it worked fairly well in their video to simply include just the header file and have the cpp file in the same directory.
further: I downloaded their source code and the problem remained. It is not my code, it is how I am trying to build my files. I am not using an IDE to build my programs (I am using Atom IDE to write programs if you know of a shortcut through there), and like stated earlier I am just running the Mingw g++ cppfile.cpp -o
command.
Besides the straight answer, if there is a way that can make building cpp projects easier please link me to it or write it here. I have had nothing but trouble in the past trying to learn this language.