2

It seems that I my program won't compile I get this error

The program file specified in the launch configuration does not exist C:\Users\User\workspaceforcpp\SDLTest\Debug\SDLTest.exe not found

but the strange thing is before I broke my code up into a more object orientated way by adding a header file and a file for screen,or in other words when I was running all the code from main it worked fine

I have also other projects with many header and cpp files and they compile just fine also

So this puzzles me as to why I am getting this error,it builds fine but no success,I have spent the last hour researching how to fix this problem and have found people with a similar problem to me but all the solutions didn't work,I tried rebuilding and cleaning the project,I also followed these steps from a user in a post I found

Right click on your project --> Properties Run/Debug settings Delete whatever is set as "launch configuration for '........' Project --> Clean Project --> Build Project

I have even tried deleting the object files and rebuilding and no success,I also checked the debug and release folder and I can't find a .exe in them,when I check my other programs not using SDL they all have a .exe in their debug or release folder

but to no avail,any suggestions?

I will post my code anyway even though as far as I know there is nothing wrong with my code

      #include <iostream>
#include "Screen.h"


using namespace std;
using namespace amc;

int main(int argc, char* argv[])
{
    Screen screen;
    screen.init();
    bool quit = false;
    SDL_Event event;

    while(!quit){

           while(SDL_PollEvent(&event)){

               if(event.key.keysym.scancode == SDL_SCANCODE_5){

                   cout << "5 pressed" << endl;

               }
              if(event.type == SDL_QUIT){

                  quit = true;
              }
           }
          }

    screen.close();
}


    #include <iostream>
#include "Screen.h"

using namespace std;

namespace amc{

  Screen:: Screen():
        window(NULL),renderer(NULL),texture(NULL),buffer(NULL)
  {

  }

  bool Screen:: init(){

      if(SDL_Init(SDL_INIT_VIDEO) < 0){

           return false;
         }
      window = SDL_CreateWindow("Particle eXplosion",SDL_WINDOWPOS_UNDEFINED,
               SDL_WINDOWPOS_UNDEFINED,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN);
      renderer = SDL_CreateRenderer(window,-1,SDL_RENDERER_PRESENTVSYNC);
      texture = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_STATIC,SCREEN_WIDTH,SCREEN_HEIGHT);
      buffer = new Uint32[SCREEN_WIDTH * SCREEN_HEIGHT];

      for(int i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++){

                 buffer[i] = 0xFFFF00FF;
         }

      SDL_UpdateTexture(texture,NULL,buffer,SCREEN_WIDTH*sizeof(Uint32));
      SDL_RenderClear(renderer);
      SDL_RenderCopy(renderer,texture,NULL,NULL);
      SDL_RenderPresent(renderer);
      return true;
  }

  bool Screen:: processEvents(){

      return false;
  }

   void Screen:: close(){


       delete [] buffer;
       SDL_DestroyRenderer(renderer);
       SDL_DestroyTexture(texture);
       SDL_Delay(9000);
       SDL_DestroyWindow(window);
       SDL_Quit();
   }

}

    #ifndef SCREEN_H_
#define SCREEN_H_
#include <SDL.h>

namespace amc{


class Screen{


private:
    SDL_Window *window;
    SDL_Renderer *renderer;
    SDL_Texture *texture;
    Uint32 *buffer;


public:
    const static int SCREEN_WIDTH;
    const static int SCREEN_HEIGHT;

public:

    Screen();
    bool init();
    bool processEvents();
    void close();


};

}

endif /* SCREEN_H_ */

edit** sorry about putting all the code in one block I'm still figuring out how to format properly,anyway the first part is main.cpp second is Screen.cpp and third is Screen.h

when I follow the steps

Right click on your project --> Properties Run/Debug settings Delete whatever is set as "launch configuration for '........' Project --> Clean Project --> Build Project

from Nenad Bulatovic from another thread on here when I run the program after all these steps I get launch failed,binary not failed

I have literally been at this for 24 hours and can't find whats wrong,there doesn't seem to be any clear cut solution

**edit #2

The program seems to build and compile fine without the so I'm guessing it's something to do with SDL but not sure what,

I tried putting the SDL.dll file in the projects folders both debug and release and even the root project folder but no success

here is what I get when I build it

14:31:28 **** Incremental Build of configuration Release for project SDL4 **** Info: Internal Builder is used for build g++ -o SDL4.exe Test.o Main.o -lmingw32 -lSDL2main -lSDL2 Test.o:Test.cpp:(.rdata$.refptr._ZN4Test12SCREEN_WIDTHE[.refptr._ZN4Test12SCREEN_WIDTHE]+0x0): undefined reference to Test::SCREEN_WIDTH' Test.o:Test.cpp:(.rdata$.refptr._ZN4Test13SCREEN_HEIGHTE[.refptr._ZN4Test13SCREEN_HEIGHTE]+0x0): undefined reference toTest::SCREEN_HEIGHT' collect2.exe: error: ld returned 1 exit status

14:31:30 Build Finished (took 2s.361ms)

note I changed the name of the class from Screen to Test(new project) but exact same results

**edit #3

I tried installing a fresh copy of eclipse and still no luck I get the same message,I also tried adding the header file to each source file,the very strange thing is I can get a SDL program to compile and run but it has to be in a single file,I'm so confused at this point I have tried everything

these are the steps I followed initially https://www.caveofprogramming.com/c-for-complete-beginners/setting-up-sdl-windows.html

**edit #4

I also tried this link http://lazyfoo.net/SDL_tutorials/lesson01/windows/eclipse/index.php and still to no avail

**edit #5 still have not found the solution =(

irishmaniac
  • 101
  • 1
  • 12

0 Answers0