Точка входа в процедуру _ZdlPvj не может быть расположена в dll $ {pathToDir} \ demoGame.exe - PullRequest
0 голосов
/ 04 февраля 2020

Я пытаюсь настроить SDL2 для создания игры на C ++ для windows. Когда я запускаю приведенный ниже файл make только с одним исходным файлом, я не получаю ошибок, и программа может работать. Когда я пытаюсь запустить файл make с несколькими исходными файлами, компиляция проходит гладко, но когда я пытаюсь запустить программу, я получаю сообщение об ошибке в заголовке. Похоже, это происходит только тогда, когда я пытаюсь создать экземпляр класса во втором исходном файле и пытаюсь получить доступ к членам или функциям экземпляра.

Я попытался заново загрузить и настроить свою среду, обновив mingw (не мешало попробовать) и трижды проверил мой код. Я включил make-файл, а также исходные файлы, которые я использую. Спасибо за любую помощь.

РЕДАКТИРОВАТЬ: Кажется, что вызов удаления в основной функции вызывает эту ошибку ... Не уверен, является ли это совпадением или если причина где-то там l ie .. .

#OBJS specifies which files to compile as part of the project
OBJS = src/*.cpp src/*.hpp

#CC specifies which compiler we're using
CC = g++

#INCLUDE_PATHS specifies the additional include paths we'll need
INCLUDE_PATHS = -Iinclude/SDL2

#LIBRARY_PATHS specifies the additional library paths we'll need
LIBRARY_PATHS = -Llib

#COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppresses all warnings
# -Wl,-subsystem,windows gets rid of the console window
COMPILER_FLAGS = 

#LINKER_FLAGS specifies the libraries we're linking against
LINKER_FLAGS = -lmingw32 -lSDL2main -lSDL2

#OBJ_NAME specifies the name of our exectuable
OBJ_NAME = demoGame

#This is the target that compiles our executable
all : $(OBJS)
    $(CC) $(OBJS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)
#include <SDL.h>
#include <stdio.h>
#include "grid.hpp"
#include <iostream>

//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int main( int argc, char* args[] )
{
    //The window we'll be rendering to
    SDL_Window* window = NULL;

    //The surface contained by the window
    SDL_Surface* screenSurface = NULL;

    //Initialize SDL
    if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
    }
    else
    {
        //Create window
        window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
        if( window == NULL )
        {
            printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
        }
        else
        {
            //Get window surface
            screenSurface = SDL_GetWindowSurface( window );

            //Fill the surface white
            SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );

            //Update the surface
            SDL_UpdateWindowSurface( window );

            //Wait two seconds
            SDL_Delay( 2000 );
        }
    }

    Grid* grid = new Grid(1, 2);

    // These two lines seem to cause an issue.
    std::cout << grid->getRows() << std::endl;
    delete grid;


    //Destroy window
    SDL_DestroyWindow( window );

    //Quit SDL subsystems
    SDL_Quit();

    return 0;
}

class Grid {
public:
    Grid(int rows, int columns) {
        this->rows = rows;
        this->columns = columns;
    }

    int getRows() {
        return this->rows;
    }

private:
    int rows;
    int columns;
};
...