0

I have been trying to debug my catch2 tests lately but everytime it fails. When I run the program, it compiles and everything seems fine. I get this error saying the exe file does not exist and offers me to configure the launch.json file.

When I press F5, "test.exe" is created in the correct folder but at the end of the build it disappears and VS Code gives me the aforenamed message. It only happens when I debug the Catch2 tests.

This is the code I've been trying to debug

#define CATCH_CONFIG_MAIN
#include "catch.hpp"

class Foo 
{
    public:
    size_t func() const
    {
        return 0;
    }
};

TEST_CASE("Some Test")
{
    Foo f;
    REQUIRE(f.func() == 0);
}

A link to the catch.hpp file included

This is the launch.json file:

"version": "0.2.0",
"configurations": [
    {
        "name": "g++.exe - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "C/C++: g++.exe build active file"
    }
]

This is the terminal output:

Starting build...
C:\msys64\mingw64\bin\g++.exe -g 
C:\Users\Owner\FMI\Semester3\SD\homework3\test.cpp -o 
C:\Users\Owner\FMI\Semester3\SD\homework3\test.exe
C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZNKSt7__cxx1112regex_traitsIcE16lookup_classnameIPKcEEN
S1_10_RegexMaskET_S6_b+0x1c): relocation truncated to fit: 
IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZNKSt7__cxx1112regex_traitsIcE16lookup_classnameIPKcEEN
S1_10_RegexMaskET_S6_b'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZNSt7__cxx1112regex_traitsIcE10_RegexMaskoRES2_+0x1c): 
relocation truncated to fit: IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZNSt7__cxx1112regex_traitsIcE10_RegexMaskoRES2_'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZNSt6vectorINSt7__cxx1112regex_traitsIcE10_RegexMaskESa
IS3_EE9push_backERKS3_+0x1c): relocation truncated to fit: 
IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZNSt6vectorINSt7__cxx1112regex_traitsIcE10_RegexMaskESa
IS3_EE9push_backERKS3_'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZNSt6vectorIcSaIcEE5beginEv+0x1c): relocation truncated
 to fit: IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZNSt6vectorIcSaIcEE5beginEv'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZNSt6vectorIcSaIcEE3endEv+0x1c): relocation truncated
 to fit: IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZNSt6vectorIcSaIcEE3endEv'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPcSt6vectorIcSa
IcEEEEEvT_S7_+0x1c): relocation truncated to fit: 
IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPcSt6vectorIcSa
IcEEEEEvT_S7_'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZSt6uniqueIN9__gnu_cxx17__normal_iteratorIPcSt6vectorIc
SaIcEEEEET_S7_S7_+0x1c): relocation truncated to fit: 
IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZSt6uniqueIN9__gnu_cxx17__normal_iteratorIPcSt6vectorIc
SaIcEEEEET_S7_S7_'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZN9__gnu_cxx17__normal_iteratorIPKcSt6vectorIcSaIcEEEC1
IPcEERKNS0_IT_NS_11__enable_ifIXsrSt10__are_sameIS9_S8_E7__valueES5_E6
__typeEEE+0x1c): relocation truncated to fit: IMAGE_REL_AMD64_SECREL 
against 
`.debug_frame$_ZN9__gnu_cxx17__normal_iteratorIPKcSt6vectorIcSaIcEEEC1
IPcEERKNS0_IT_NS_11__enable_ifIXsrSt10__are_sameIS9_S8_E7__valueES5_E6
__typeEEE'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZNSt6vectorIcSaIcEE5eraseEN9__gnu_cxx17__normal_iterato
rIPKcS1_EES6_+0x1c): relocation truncated to fit: 
IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZNSt6vectorIcSaIcEE5eraseEN9__gnu_cxx17__normal_iterato
rIPKcS1_EES6_'

C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZNSt8__detail15_BracketMatcherINSt7__cxx1112regex_trait
sIcEELb0ELb0EE13_M_make_cacheESt17integral_constantIbLb1EE+0x1c): 
relocation truncated to fit: IMAGE_REL_AMD64_SECREL against 
`.debug_frame$_ZNSt8__detail15_BracketMatcherINSt7__cxx1112regex_trait
sIcEELb0ELb0EE13_M_make_cacheESt17integral_constantIbLb1EE'


C:\Users\Owner\AppData\Local\Temp\cc12ZF2g.o:test.cpp:
(.debug_frame$_ZSt4moveIRNSt12_Vector_baseIcSaIcEE12_Vector_implEEONSt
16remove_referenceIT_E4typeEOS6_+0x1c): additional relocation 
overflows omitted from the output

collect2.exe: error: ld returned 1 exit status

Build finished with error(s).

Terminal will be reused by tasks, press any key to close it.


  • I imagine one of [these](https://stackoverflow.com/search?q=relocation+truncated+to+fit) is a duplicate, something in your code is too big, please show a [mre]. The executable is disappearing at the end of the build because it failed to build so the linker deleted the incompletely built file – Alan Birtles Jan 08 '22 at 14:12
  • ***When I press F5, "test.exe" is created in the correct folder but at the end of the build it disappears*** Maybe your Antivirus is the problem. Some AV will suspect your c++ program as suspicious because the executable is not signed and the file is not a popular file that the AV has seen millions of times and recorded its signature in its database – drescherjm Jan 08 '22 at 14:18
  • @AlanBirtles Thanks for the remark! I uploaded a short version of the code which still fails the same way – Petur Chuklev Jan 08 '22 at 15:15
  • @drescherjm Thanks! There aren't any warnings or notifications for actions taken from the AV during the building – Petur Chuklev Jan 08 '22 at 15:23

0 Answers0