'Starting the debuggee failed: No executable specified, use `target exec'

Code:

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
// to generate numbers
void gen_data(int b[], int n)
{
    int i;
    for (i = 0; i < n; i++)
        b[i] = rand() % 101;
}
// to display numbers
void disp_data(int b[], int n)
{
    int i;
    for (i = 0; i < n; i++)
        printf("%d \n", b[i]);
}
// insert at desired posn
void insert(int b[], int n, int elt, int pos)
{
    int i;
    for (i = n - 1; i >= pos; i--)
        b[i + 1] = b[i];
    b[pos] = elt;
}
// delete an elt at given position
void delete (int b[], int n, int pos)
{
    int i;
    for (i = pos + 1; i < n; i++)
        b[i - 1] = b[i];
}
// driver code
int main()
{
    int a[100], pos, n = 10, let;
    int opt;
    system("cls");
    gen_data(a, n);
    while (1)
    {
        printf("\n 1- Insert 2-Delete 3-Display 4-quit\n");
        scanf("%d %d", &pos, &elt);
        insert(a, n, elt, pos);
        n++;
        break;
        case 2:
            printf("enter position at which elt to be deleted: ");
            scanf("%d", &pos);
            delete (a, n, pos);
            n--;
            break;
        case 3:
            printf("the numbers are : \n");
            disp_data(a, n);
            break;
    }
    if (opt == 4)
        break;
} // end while
}

Log:

Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target: 
Debug
Adding source dir: C:\Users\Ranju\Desktop\you\lab pro\
Adding source dir: C:\Users\Ranju\Desktop\you\lab pro\
Adding file: C:\Users\Ranju\Desktop\you\lab pro\bin\Debug\lab pro.exe
Changing directory to: "C:/Users/Ranju/Desktop/you/lab pro/."
Set variable: PATH=.;C:\MinGW\bin;C:\MinGW;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C;C:\Users\Ranju\AppData\Local\Microsoft\WindowsApps;C:\Program Files\CodeBlocks\MinGW\bin
Starting debugger: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet  -args "C:/Users/Ranju/Desktop/you/lab pro/bin/Debug/lab pro.exe"
done
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 8.1
Starting the debuggee failed: No executable specified, use `target exec'.
Debugger finished with status 0


Solution 1:[1]

In my case, removing space(s) from the project path resolved the problem. Maybe you should try to change path like this: "C:/Users/Ranju/Desktop/you/labpro/bin/Debug/lab pro.exe"

Solution 2:[2]

I don't know how relevant this may be, but I seem to have the same or similar problem. See the material at

How do you debug using 'Code::Blocks 20.03' (the "mingw" version)?

especially that after the sentence, I have hopefully made progress towards an answer..


I have now added a proper answer to the above question..


I asume that you have MinGW installed, in the directory C:\MinGW.

Perhaps, AT YOUR OWN RISK, you could try temporarily renaming the folder C:\MinGW to something else, and try running the debugger.

I had MinGW pre-installed, when I installed Code::Blocks 20.03 using codeblocks-20.03mingw-setup.exe ( the 8th April 2021 version , default installation accepted). I also had a problem debugging. There is now a fix for this, which seems quite general, applying even without a pre-installed MinGW, see the answer to the other question ( link provided above ).

The fix involves changing a debugger setting, but in your case, you seem to be trying to use the correct debugger, see the line that you give, which is shown just below

Starting debugger: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet -args "C:/Users/Ranju/Desktop/you/lab pro/bin/Debug/lab pro.exe"

In the above, you appear to be trying to use a debugger, from the directory, C:\Program Files\Codeblocks\MinGW\bin, which seems O.K., rather than one from C:\MinGW\bin, which is where the debugger was, that I was trying to use, see the other question.

However, you may be using something other than the debugger from the directory C:\MinGW.


Whether or not you have MinGW installed in C:\MinGW, you may need to alter some Setting in Code::Blocks.

Solution 3:[3]

I recently had the same issue when starting to use CodeBlocks on Windows10 (C::B version 20.03 in my case). The problem was that I also had MinGW installed long before I installed CodeBlocks and CodeBlocks took the gdb.exe from that path instead of taking it from the MinGW path that was installed within CodeBlocks. The solution for me was to change the default executable path in Settings -> Debugger... -> GDB/CDB debugger -> Default to the gdb.exe that was installed when I installed CodeBlocks. So: <C::B_installation_path>\MinGW\bin\gdb.exe.

After that change, the problem was solved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 0x07B8
Solution 2
Solution 3 GeertVc