I’m looking for some help with running C++ code. Although “PhysicsThread” and “main” is defined once in the file I got “multiple definition error”. Also, for the “no such file or directory” error I do not have a solution as well.
Here is the written version of the error:
<code>Starting build...
cmd /c chcp 65001>nul && C:mingw64bing++.exe -fdiagnostics-color=always simulate main.cc -L C:UsersuserDesktopmujoco-3.1.6-windows-x86_64lib -g -lmujoco -std=c++20 C:UsersuserDesktopmujoco-3.1.6-windows-x86_64simulatemain.cc -o C:UsersuserDesktopmujoco-3.1.6-windows-x86_64simulatemain.exe
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find simulate: No such file or directory
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:UsersuserAppDataLocalTempccyRGBhE.o: in function PhysicsThread(mujoco::Simulate*, char const*)': C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:427: multiple definition of PhysicsThread(mujoco::Simulate*, char const*)'; C:UsersuserAppDataLocalTempcczp5o05.o:C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:427: first defined here
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:UsersuserAppDataLocalTempccyRGBhE.o: in function main': C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:475: multiple definition of main'; C:UsersuserAppDataLocalTempcczp5o05.o:C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:475: first defined here
collect2.exe: error: ld returned 1 exit status
</code>
<code>Starting build...
cmd /c chcp 65001>nul && C:mingw64bing++.exe -fdiagnostics-color=always simulate main.cc -L C:UsersuserDesktopmujoco-3.1.6-windows-x86_64lib -g -lmujoco -std=c++20 C:UsersuserDesktopmujoco-3.1.6-windows-x86_64simulatemain.cc -o C:UsersuserDesktopmujoco-3.1.6-windows-x86_64simulatemain.exe
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find simulate: No such file or directory
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:UsersuserAppDataLocalTempccyRGBhE.o: in function PhysicsThread(mujoco::Simulate*, char const*)': C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:427: multiple definition of PhysicsThread(mujoco::Simulate*, char const*)'; C:UsersuserAppDataLocalTempcczp5o05.o:C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:427: first defined here
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:UsersuserAppDataLocalTempccyRGBhE.o: in function main': C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:475: multiple definition of main'; C:UsersuserAppDataLocalTempcczp5o05.o:C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:475: first defined here
collect2.exe: error: ld returned 1 exit status
</code>
Starting build...
cmd /c chcp 65001>nul && C:mingw64bing++.exe -fdiagnostics-color=always simulate main.cc -L C:UsersuserDesktopmujoco-3.1.6-windows-x86_64lib -g -lmujoco -std=c++20 C:UsersuserDesktopmujoco-3.1.6-windows-x86_64simulatemain.cc -o C:UsersuserDesktopmujoco-3.1.6-windows-x86_64simulatemain.exe
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find simulate: No such file or directory
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:UsersuserAppDataLocalTempccyRGBhE.o: in function PhysicsThread(mujoco::Simulate*, char const*)': C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:427: multiple definition of PhysicsThread(mujoco::Simulate*, char const*)'; C:UsersuserAppDataLocalTempcczp5o05.o:C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:427: first defined here
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:UsersuserAppDataLocalTempccyRGBhE.o: in function main': C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:475: multiple definition of main'; C:UsersuserAppDataLocalTempcczp5o05.o:C:/Users/user/Desktop/mujoco-3.1.6-windows-x86_64/simulate/main.cc:475: first defined here
collect2.exe: error: ld returned 1 exit status
For “No such file or directory” part, I gave input to run the necessary function but it did not help. For the mentioned two functions, I checked whether there are more than one in the file and script. But both functions are only one time used in the file.
New contributor
Efe Can Albay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.