My Case is as follows:
I made a GUI program (wxWidgets based) on Microsoft Visual Studio where this code was running fine mixing both C++ and C files, basically the C files do very little things but I can't discard them cause I am very beginner with C++ OOP - I have OOP background from Java which I feel far different than C++ - but I can deal with it to certain extent. Anyway, the program was running fine on Visual Studio 2019 but when I place it on another computer with no Visual Studio installation, it start firing missing .dll
s after little research I found this is due to the lack of Visual Studio installation on that computer and I don't have admin rights to install these .dll
files. I looked for rebuilding the files on VS Code, I used the g++ compiler so I needed to configure wxWidgets with MinGw compiler. I managed to make the Hello World code on wxWidgets work. When I ran my code it didn't work after a little bit of struggle I eliminated any errors, however when I built the code for Debug/Release this what it get on the terminal:
C:\Users<USER>\AppData\Local\Temp\ccUB3ReN.o: In function
ZN5cMainC2Ev
: C:/Users//Desktop/wxTest/src/cMain.cpp:13: undefined reference toBus_Construct
C:/Users//Desktop/wxTest/src/cMain.cpp:13: undefined reference toDecker_Construct
C:\Users<USER>\AppData\Local\Temp\ccUB3ReN.o: In functionZN5cMain16CalculateClickedER14wxCommandEvent
: C:/Users//Desktop/wxTest/src/cMain.cpp:426: undefined reference togetCG
C:/Users//Desktop/wxTest/src/cMain.cpp:442: undefined reference togetCGz
C:/Users//Desktop/wxTest/src/cMain.cpp:454: undefined reference togetPassCGX
C:/Users//Desktop/wxTest/src/cMain.cpp:455: undefined reference togetPassCGY
C:/Users//Desktop/wxTest/src/cMain.cpp:456: undefined reference togetPassCGZ
C:/Users//Desktop/wxTest/src/cMain.cpp:457: undefined reference tototalCG
C:/Users//Desktop/wxTest/src/cMain.cpp:470: undefined reference todelay
C:/Users//Desktop/wxTest/src/cMain.cpp:528: undefined reference tofreeSeats
C:/Users//Desktop/wxTest/src/cMain.cpp:530: undefined reference tofreeSingleDecker
C:\Users<USER>\AppData\Local\Temp\ccUB3ReN.o: In functionZN5cMain19GenerateGroupsClickER14wxCommandEvent
: C:/Users//Desktop/wxTest/src/cMain.cpp:622: undefined reference toinitSingleDecker
C:/Users//Desktop/wxTest/src/cMain.cpp:627: undefined reference toinitSeats
collect2.exe: error: ld returned 1 exit status The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command C:<USER>\Softwares\MinGW\mingw32\bin\g++.exe -g C:\Users<USER>\Desktop\wxTest\src*.cpp C:\Users<USER>\Desktop\wxTest\src*.c -o C:\Users<USER>\Desktop\wxTest\build\debug\cApp.exe -I C:\Users<USER>\Desktop\wxTest\include -I C:\wx\wxWidgets-3.1.5\include -I C:\wx\wxWidgets-3.1.5\lib\gcc_dll\mswud -L C:\wx\wxWidgets-3.1.5\lib\gcc_dll -l wxmsw31ud_core -l wxbase31ud" terminated with exit code: 1
What I noticed is some mangled name with ZN5cMainC2Ev
which originally a class name cMain.
I think the trick is at the task.json
arguments:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Debug",
"command": "C:\\Amir\\Softwares\\MinGW\\mingw32\\bin\\g++.exe",
"args": [
"-g",
"${workspaceFolder}\\src\\*.cpp",
"-o",
"${workspaceFolder}\\build\\debug\\${fileBasenameNoExtension}.exe",
"-I",
"${workspaceFolder}\\include",
"-I",
"C:\\wx\\wxWidgets-3.1.5\\include",
"-I",
"C:\\wx\\wxWidgets-3.1.5\\lib\\gcc_dll\\mswud",
"-L",
"C:\\wx\\wxWidgets-3.1.5\\lib\\gcc_dll",
"-l",
"wxmsw31ud_core",
"-l",
"wxbase31ud",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: C:\\Amir\\Softwares\\MinGW\\mingw32\\bin\\g++.exe"
},
{
"type": "shell",
"label": "Release",
"command": "C:\\Amir\\Softwares\\MinGW\\mingw32\\bin\\g++.exe",
"args": [
"${workspaceFolder}\\src\\*.cpp",
"${workspaceFolder}\\src\\BusCalcs.c",
"${workspaceFolder}\\src\\CG_Engine.c",
"${workspaceFolder}\\src\\Helper.c",
"-o",
"${workspaceFolder}\\build\\release\\${fileBasenameNoExtension}.exe",
"-I",
"${workspaceFolder}\\include",
"-I",
"C:\\wx\\wxWidgets-3.1.5\\include",
"-I",
"C:\\wx\\wxWidgets-3.1.5\\lib\\gcc_dll\\mswu",
"-L",
"C:\\wx\\wxWidgets-3.1.5\\lib\\gcc_dll",
"-l",
"wxmsw31u_core",
"-l",
"wxbase31u",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: C:\\Amir\\Softwares\\MinGW\\mingw32\\bin\\g++.exe"
}
]
}