tdelame / codingame_vscode_extension

VSCode extension to ease the development of C++ CodinGame bot
MIT License
1 stars 1 forks source link

unit_tests_cpp error #3

Open jordiboni opened 2 years ago

jordiboni commented 2 years ago

Followed your steps for Windows but getting this error when trying to build your starter project

> Executing task: ninja <

[2/4] Building CXX object CMakeFiles/unit_tests.dir/tests/unit_tests.cpp.obj
FAILED: CMakeFiles/unit_tests.dir/tests/unit_tests.cpp.obj 
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -IC:/Users/jbonastre/Documents/CodinGame/tools/include -IC:/Users/jbonastre/Documents/CodinGame/MyTest1/src -IC:/Users/jbonastre/Documents/CodinGame/MyTest1/tests -O3 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ggdb3 -D_GLIBCXX_ASSERTIONS=1 -std=c++17 -Wall -Wextra -Wconversion -Wshadow-all -Wno-shadow-field-in-constructor -Wno-format-security -m64 -MD -MT CMakeFiles/unit_tests.dir/tests/unit_tests.cpp.obj -MF CMakeFiles\unit_tests.dir\tests\unit_tests.cpp.obj.d -o CMakeFiles/unit_tests.dir/tests/unit_tests.cpp.obj -c C:/Users/jbonastre/Documents/CodinGame/MyTest1/tests/unit_tests.cpp
C:/Users/jbonastre/Documents/CodinGame/MyTest1/tests/unit_tests.cpp:2:11: fatal error: 'catch.hpp' file not found
# include "catch.hpp"
          ^~~~~~~~~~~
1 error generated.
[3/4] Linking CXX executable ..\bin\bot.exe
FAILED: ../bin/bot.exe
cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -fuse-ld=lld-link -nostartfiles -nostdlib -O3 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ggdb3 -D_GLIBCXX_ASSERTIONS=1 -fuse-ld=lld -Xlinker /subsystem:console CMakeFiles/bot.dir/src/bot.cpp.obj -o ..\bin\bot.exe -Xlinker /MANIFEST:EMBED -Xlinker 
/implib:..\lib\bot.lib -Xlinker /pdb:..\bin\bot.pdb -Xlinker /version:0.0  -LC:/Users/jbonastre/Documents/CodinGame/tools/lib -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cmd.exe /C "cd /D C:\Users\jbonastre\Documents\CodinGame\MyTest1\build && 
python C:/Users/jbonastre/Documents/CodinGame/MyTest1/merge_source_files.py C:/Users/jbonastre/Documents/CodinGame/MyTest1/src/bot.cpp C:\Users\jbonastre\Documents\CodinGame\tools\include C:/Users/jbonastre/Documents/CodinGame/MyTest1/package/bot.cpp""
lld-link: error: <root>: undefined symbol: mainCRTStartup
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.
tdelame commented 2 years ago

You're right. I've let catch header include in the starter project. I'll remove it.

In the meantime, you can either:

tdelame commented 2 years ago

I committed a fix but unfortunately, I won't have the opportunity to test it myself soon. If you still have any issues, let me know.

jordiboni commented 2 years ago

Gotcha, it has been fixed removing the line from CMakeLists.txt. Now I'm facing another issue. Should I open a new issue or can we have a look with this one?

Thank you for the quick response!

> Executing task: ninja <

[0/1] Re-running CMake...
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/jbonastre/Documents/CodinGame/aaaaa/build
[1/1] Linking CXX executable ..\bin\bot.exe
FAILED: ../bin/bot.exe 
cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -fuse-ld=lld-link -nostartfiles -nostdlib -O3 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ggdb3 -D_GLIBCXX_ASSERTIONS=1 -fuse-ld=lld -Xlinker /subsystem:console CMakeFiles/bot.dir/src/bot.cpp.obj -o ..\bin\bot.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:..\lib\bot.lib -Xlinker /pdb:..\bin\bot.pdb -Xlinker /version:0.0  -LC:/Users/jbonastre/Documents/CodinGame/tools/lib -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cmd.exe /C "cd /D C:\Users\jbonastre\Documents\CodinGame\aaaaa\build && python C:/Users/jbonastre/Documents/CodinGame/aaaaa/merge_source_files.py C:/Users/jbonastre/Documents/CodinGame/aaaaa/src/bot.cpp C:\Users\jbonastre\Documents\CodinGame\tools\include C:/Users/jbonastre/Documents/CodinGame/aaaaa/package/bot.cpp""
lld-link: error: <root>: undefined symbol: mainCRTStartup
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.
tdelame commented 2 years ago

I guess we could look at this problem in the same issue. This error reminds me of what I got when I first tried the clang + lld configuration on Windows. I add to pass extra cmake arguments to make it work. Go to the extension settings and enter -DCMAKE_SYSTEM_NAME="Generic" into the field Codin Game: Cmake Extra.

I really wanted to keep using clang on Windows for the nice error/warning messages, but it's still a pain to make it work ^^.

jordiboni commented 2 years ago

Same error, these are my settings:

Captura de pantalla 2021-11-23 a las 8 55 40

tdelame commented 2 years ago

For some reasons, I remember that I also specified the C compiler path, however, I think it won't help with your issue. Did you reconfigure the build after you changed the CMake Extra value?

jordiboni commented 2 years ago

yes, I tried with Debug and Release configs

Captura de pantalla 2021-11-23 a las 9 00 11

tdelame commented 2 years ago

Ok, I'll try and check the whole process on a new computer

jordiboni commented 2 years ago

Interesting, I've created a new project and we can move one step forward

It complains about python now, py is the keyword recognized on Win


> Executing task: ninja <

[2/2] Linking CXX executable ..\bin\bot
FAILED: ../bin/bot 
cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -O3 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ggdb3 -D_GLIBCXX_ASSERTIONS=1 -fuse-ld=lld CMakeFiles/bot.dir/src/bot.cpp.obj -o ..\bin\bot -LC:/Users/jbonastre/Documents/CodinGame/tools/lib  && cmd.exe /C "cd /D C:\Users\jbonastre\Documents\CodinGame\testProject1\build && python C:/Users/jbonastre/Documents/CodinGame/testProject1/merge_source_files.py C:/Users/jbonastre/Documents/CodinGame/testProject1/src/bot.cpp C:\Users\jbonastre\Documents\CodinGame\tools\include C:/Users/jbonastre/Documents/CodinGame/testProject1/package/bot.cpp""
'python' is not recognized as an internal or external command,
operable program or batch file.
ninja: build stopped: subcommand failed.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.
jordiboni commented 2 years ago

Changed CMakelist, it seems to have been finished

> Executing task: ninja <

[0/1] Re-running CMake...
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/jbonastre/Documents/CodinGame/testProject1/build
[1/1] Linking CXX executable ..\bin\bot

Terminal will be reused by tasks, press any key to close it.
tdelame commented 2 years ago

That reminds me of something. I think that went I set up the CMake Extra variable I had to remove the whole build to see the effect of changes: you cannot change toolchain on a CMake build, you have to recreate it from scratch. For the python issue, the most probable reason is it is missing from the path. Did you add the python's binary directory to the path? I had to add C:\Users\atom\AppData\Roaming\Python\Python39\Scripts to mine.