Believe me, I've been through several posts on here, but none of them addressed the issue I'm having. I have this 2-year-old program that used to run. I'm kind of reviving it, but for some reason now it does not run.
Clearly, I'm having multiple definitions (too many of them):
============================ TERMINAL OUTPUT =============================
build_files/LinkedStack.o: In function `LinkedStack':
/home/owner/workspace/opencv-galaxies/utilities/structures/LinkedStack.cpp:12: multiple definition of `LinkedStack::LinkedStack()'
build_files/LinkedStack.o:/home/owner/workspace/opencv-galaxies/utilities/structures/LinkedStack.cpp:12: first defined here
... and so on, and so forth, ... and it all ends with:
collect2: ld returned 1 exit status
make: *** [executables/Assignment3.out] Error 1
========================================================================
Strangely, the linker does not indicate any errors throughout the extensive list of warnings, not to mention that these aren't true multiple definitions. Note that each warning in a "multiple...-first defined... " pair refers to the same line. Now I don't know what to do.
I'm wondering if it has something to do with the rather busy syntax of our makefile (though it looks really good to me):
=============================== MAKEFILE =================================
CFLAGS = -g -Wno-deprecated
OBJECTS = utilities/basic/image.h build_files/image.o build_files/ReadImage.o build_files/ReadImageHeader.o build_files/WriteImage.o build_files/LinkedStack.o build_files/unsortedList.o build_files/region.o build_files/Main.o
executables/Assignment3.out: $(OBJECTS)
g++ $(OBJECTS) -o executables/Assignment3.out build_files/*.o $(CFLAGS) -lncurses
...
build_files/LinkedStack.o: utilities/structures/LinkedStack.h utilities/structures/LinkedStack.cpp
g++ -c $(CFLAGS) utilities/structures/LinkedStack.cpp -o build_files/LinkedStack.o
...
clean:
rm build_files/*.o executables/Assignment3.out
=========================================================================
So, these are my questions: 1) why did the linker see an error and 2) why am I having so many multiple definitions?
If you want a clarification, let me know even if you kind of have an idea of what's going on.
============================== CODE EXAMPLE ==============================
Here's the full example function (I don't want to make this too long):
//constructor
LinkedStack::LinkedStack()
{
topPtr = NULL; //set top pointer to null
}
========================================================================