Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why am I getting a "unidentified reference to 'dateType::dateType()'?

+6 votes
asked Apr 3, 2025 by Samuel Zengene (180 points)

Here's the fulll error message:

/usr/bin/ld: /tmp/cc3eosgO.o: in function `main':
main.cpp:(.text+0x2a): undefined reference to `dateType::dateType()'
/usr/bin/ld: main.cpp:(.text+0x48): undefined reference to `dateType::dateType(int, int, int)'
/usr/bin/ld: main.cpp:(.text+0x66): undefined reference to `dateType::dateType(int, int, int)'
/usr/bin/ld: main.cpp:(.text+0x75): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0xac): undefined reference to `dateType::setDate(int, int, int)'
/usr/bin/ld: main.cpp:(.text+0xbb): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0xf2): undefined reference to `dateType::setDate(int, int, int)'
/usr/bin/ld: main.cpp:(.text+0x101): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x138): undefined reference to `dateType::setDate(int, int, int)'
/usr/bin/ld: main.cpp:(.text+0x147): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x17e): undefined reference to `dateType::setDate(int, int, int)'
/usr/bin/ld: main.cpp:(.text+0x18d): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x1b5): undefined reference to `dateType::incrementDate()'
/usr/bin/ld: main.cpp:(.text+0x1c4): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x1ec): undefined reference to `dateType::incrementDate()'
/usr/bin/ld: main.cpp:(.text+0x1fb): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x232): undefined reference to `dateType::setDate(int, int, int)'
/usr/bin/ld: main.cpp:(.text+0x241): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x269): undefined reference to `dateType::incrementDate()'
/usr/bin/ld: main.cpp:(.text+0x278): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x2a0): undefined reference to `dateType::printDashDate() const'
/usr/bin/ld: main.cpp:(.text+0x2c8): undefined reference to `dateType::printTextDate() const'
/usr/bin/ld: main.cpp:(.text+0x2f0): undefined reference to `dateType::printLongTextDate() const'
/usr/bin/ld: main.cpp:(.text+0x318): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x340): undefined reference to `dateType::decrementDate()'
/usr/bin/ld: main.cpp:(.text+0x34f): undefined reference to `dateType::printSlashDate() const'
/usr/bin/ld: main.cpp:(.text+0x39d): undefined reference to `dateType::equalDate(dateType const&) const'
/usr/bin/ld: main.cpp:(.text+0x403): undefined reference to `dateType::dayOfWeek[abi:cxx11]() const'
/usr/bin/ld: main.cpp:(.text+0x44a): undefined reference to `dateType::~dateType()'
/usr/bin/ld: main.cpp:(.text+0x459): undefined reference to `dateType::~dateType()'
/usr/bin/ld: main.cpp:(.text+0x468): undefined reference to `dateType::~dateType()'
/usr/bin/ld: main.cpp:(.text+0x4ad): undefined reference to `dateType::~dateType()'
/usr/bin/ld: main.cpp:(.text+0x4c5): undefined reference to `dateType::~dateType()'
/usr/bin/ld: /tmp/cc3eosgO.o:main.cpp:(.text+0x4dd): more undefined references to `dateType::~dateType()' follow
collect2: error: ld returned 1 exit status
I don't understand. I'm using a coding class for one of my assignments.

1 Answer

0 votes
answered Apr 7, 2025 by Peter Minarik (101,420 points)
edited Apr 7, 2025 by Peter Minarik

Probably you have a dateType class declaration in a header file, but you do not have the implementation in any cpp file.

Is it your own type or does it come from some 3rd party library?

commented Apr 8, 2025 by Samuel Zengene (180 points)
It's my own type
commented Apr 10, 2025 by Peter Minarik (101,420 points)
So you're probably missing the implementation. Implementations, to be exact as there are many functions that are unresolved based on the error messages.

If you need further help, please, share your code.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...