I’m trying to develop a c++ application on NixOS, I’ve created a nix shell script that i want to use for development, which provides me with the correct version of Ninja, CMake, GCC and GDB. Something along the lines of this snippet.
For development I’m using VSCode with the CMake extension and Nix Environment Selector.
I can use the CMake extension without problem for building and launching my project, but as soon as i try to launch the debugger I get the following output.
[build] ninja: no work to do.
[driver] Build completed: 00:00:00.056
[build] Build finished with exit code 0
[proc] Executing command: /nix/store/ypf4h1vcw9pm93wqrfs9796mm01d59s3-gcc-wrapper-13.2.0/bin/gdb --version
[proc] The command: /nix/store/ypf4h1vcw9pm93wqrfs9796mm01d59s3-gcc-wrapper-13.2.0/bin/gdb --version exited with code: 127
[proc] Executing command: gdb --version
And then it simply stopped. When i try to run gdb --version in the nix-shell i get this output:
[nix-shell:~/my-project]$ gdb --version
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
I also tried to launch the debugger directly with the VSCode launch files, but there it simply loads for a second, and the nothing happens.
Has anyone an idea on how to fix this?
and VSCode with the Nix Enviroment Selector, CMake Tools, and C/C++ extensions, I was able to set a breakpoint and successfully run Debug (under Project Status, in the CMake tab).
Even doing so, the Output shown for CMake/Build was the same as what you have; so that’s not necessarily an issue:
[main] Building folder: nix-cpp-debug all
[build] Starting build
[proc] Executing command: /nix/store/0xpv46mb188z226j7cs211zmmi5xw9nj-cmake-3.29.1/bin/cmake --build /home/rgoulter/playground/nix-cpp-debug/build --config Debug --target all --
[build] ninja: no work to do.
[driver] Build completed: 00:00:00.030
[build] Build finished with exit code 0
[proc] Executing command: /nix/store/k9pxn9rdy5d2081612zx4i177kzzyvkn-gcc-wrapper-13.2.0/bin/gdb --version
[proc] The command: /nix/store/k9pxn9rdy5d2081612zx4i177kzzyvkn-gcc-wrapper-13.2.0/bin/gdb --version exited with code: 127
[proc] Executing command: gdb --version
I did this on NixOS. Are you able to debug this simple C++ project?
thanks for your reply, unfortunally, I’m not able to debug even this simple example. When i try to launch the debugger, it simply redirects me to the Run and Debug window of VS Code but nothing more happens, I’m on NixOS 23.11 and VSCode version 1.85.2.