Recently, I learned the C + + program video of dark horse. When I realized the employee management system based on polymorphism, I knocked the same code as the video, but I couldn’t compile it successfully by using vscode, and the following errors occurred:
[Employee_Management_System.cpp 2021-10-22 13:58:17.099]
,,C:\Users\AAE3~1\AppData\Local\Temp\cc7ZdaG7.o:Employee_Management_System.cpp:(.text+0x1b): undefined reference to `WorkerManager::WorkerManager()'
C:\Users\AAE3~1\AppData\Local\Temp\cc7ZdaG7.o:Employee_Management_System.cpp:(.text+0x27): undefined reference to `WorkerManager::Show_Menu()'
C:\Users\AAE3~1\AppData\Local\Temp\cc7ZdaG7.o:Employee_Management_System.cpp:(.text+0x44): undefined reference to `WorkerManager::~WorkerManager()'
C:\Users\AAE3~1\AppData\Local\Temp\cc7ZdaG7.o:Employee_Management_System.cpp:(.text+0x57): undefined reference to `WorkerManager::~WorkerManager()'
collect2.exe: error: ld returned 1 exit status
After querying many blogs, it is found that the causes and solutions of errors such as collect.exe: error: 1D returned 1 exit status are as follows
1. The last compiled program is not closed, that is, the black box still exists. Find it and close or restart the IDE
2. The program has no main function or the main function is misspelled
3. Running in vscode will not help you save the code. You need to save the code before running
4. The file name and file path may cause errors in some compilers
5. There is an undefined reference. This is the case for this error. When instantiating the classes of other files in the main function, you need to define the .H file and .Cpp file of other classes to solve the problem.
#include<iostream>
#include"workerManager.h"
#include"workerManager.cpp"
Read More:
- VSCode Error: collect2.exe: error: ld returned 1 exit status
- [Solved] VScode Error: undefined reference to ‘WinMain’ collect2.exe: error: ld returned 1 exit status
- GCC Error:(.text+0x24): undefined reference to `main‘collect2: error: ld returned 1 exit status [Solved]
- [Solved] error adding symbols: File in wrong format collect2: error: ld returned 1 exit status
- [Solved] VsCode + gfortran Compiler Error: error: ld returned 1 exit status
- DevC++ Error: [Error] Id returned 1 exit status [How to Solve]
- Ubutnu Qt Unable to start process Error: “make“ -f ‘ /usr/bin/ld: cannot find -lGL collect2: error: ld returned 1 exit sta
- [Solved] VScode Error: PS D:\vscode> cd “d:\vscode\“ ; if ($?) { g++ tempCodeRunnerFile.cpp -o tempCodeRunn
- Dev C++ Error: error: ld returned 1 exit status [How to Solve]
- vscode: Error loading workspace: err: exit status 1: stderr: build flag -mod=readonly only valid
- How to Solve VScode 2022 error: msvcp110d.dll not found
- [Solved] Unity Package Error: Failed running D:\Program Files\Unity2018.4.1\Editor\Data\il2cpp/build/il2cpp.exe
- NVM use error: exit status [How to Solve]
- docker load Error processing tar file(exit status 1): archive/tar: invalid tar header
- [Solved] error getting credentials – err: exit status GDBus.Error:org.freedesktop.DBus.Error.ServiceU
- Linux: tar Unpack .tar.bz2 File Error tar: Child returned status 2 tar: Error is not recoverable: exiting now
- [Solved] Vscode error: Unable to resolve resource walkThrough://vscode_getting_started_page
- After SpringBoot starts, exit the console directly and display Process finished with exit code 1
- Clickhouse error: XXXX.XXXX_local20211009 (8fdb18e9-bb4c-42d8-8fdb-18e9bb4c02d8): auto…
- tf.nn.dilation2d Call Error: TypeError: dilation2d_v1() got an unexpected keyword argument ‘data_format’