I'm almost always getting this error message which is preventing me from running my program, the following is the full message i receive. If anyone has a solution or can translate this stuff I would be very grateful :) I'm using Netbeans with MinGW (as you may be able to tell) if that is helpful at all.
"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/James/Documents/Programming/String Functions'
"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/string_functions.exe
make.exe[2]: Entering directory `/c/Users/James/Documents/Programming/String Functions'
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/string_functions build/Debug/MinGW-Windows/_ext/2032876869/substr2.o build/Debug/MinGW-Windows/substr.o
build/Debug/MinGW-Windows/substr.o: In function `main':
C:\Users\James\Documents\Programming\String Functions/substr.cpp:6: multiple definition of `main'
build/Debug/MinGW-Windows/_ext/2032876869/substr2.o:C:\Users\James\Documents\Programming\String Functions/../String Functions/substr2.cpp:7: first defined here
collect2: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/string_functions.exe] Error 1
make.exe[2]: Leaving directory `/c/Users/James/Documents/Programming/String Functions'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/James/Documents/Programming/String Functions'
make.exe": *** [.build-impl] Error 2
I think the error is this part ... multiple definition of 'main'. You can only have one entry point (in this case 'int main') per application, and each project should have it's own folder to help you keep organized. These are the most common causes of this error in my experience.
A program is only allowed a single definition of a non-static function (i.e. one that isn't limited to file scope by using the static keyword.) And main() cannot ever file scope, as it's the program entrypoint.
From
../String Functions/substr.cpp:6: multiple definition of `main'
and
../String Functions/substr2.cpp:7: first defined here
it looks like you have a main() in both substr.cpp (at line 6) and substr2.cpp (at line 7)
If you want to build an exe which uses both substr.cpp and substr2.cpp, would need to get rid of one of the main() functions (either delete or rename.)
Well now I feel a little stupid after u guys have given such a simple solution. Thank you so much for this quick and easy solution (I did simple have two source files under the same project, resulting in two 'int mains'). I'll make sure to remember this, thanks again :)