在dll${pathToDir}\demoGame.exe中找不到过程入口点_ZdlPvj 我试图建立SDL2来创建一个Windows的C++游戏。当我只使用一个源文件运行下面的make文件时,不会出现错误,程序也可以运行。当我尝试使用多个源文件运行make文件时,编译会顺利进行,但当我尝试运行程序时,会出现标题中显示的错误。只有在尝试在第二个源文件中创建类的实例,并尝试访问成员或实例函数时,才会出现这种情况
我已经尝试过重新下载和设置我的环境,更新mingw(尝试没有什么坏处),并对我的代码进行三重检查。我已经包括了makefile,以及我正在使用的源文件。谢谢你的帮助 编辑:似乎是主函数中的删除调用导致了此错误。。。不确定这是巧合还是原因就在那里在dll${pathToDir}\demoGame.exe中找不到过程入口点_ZdlPvj 我试图建立SDL2来创建一个Windows的C++游戏。当我只使用一个源文件运行下面的make文件时,不会出现错误,程序也可以运行。当我尝试使用多个源文件运行make文件时,编译会顺利进行,但当我尝试运行程序时,会出现标题中显示的错误。只有在尝试在第二个源文件中创建类的实例,并尝试访问成员或实例函数时,才会出现这种情况,c++,windows,sdl,sdl-2,C++,Windows,Sdl,Sdl 2,我已经尝试过重新下载和设置我的环境,更新mingw(尝试没有什么坏处),并对我的代码进行三重检查。我已经包括了makefile,以及我正在使用的源文件。谢谢你的帮助 编辑:似乎是主函数中的删除调用导致了此错误。。。不确定这是巧合还是原因就在那里 #OBJS specifies which files to compile as part of the project OBJS = src/*.cpp src/*.hpp #CC specifies which compiler we're us
#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)
我认为这是因为游戏从
路径中的一些随机位置拾取了它所依赖的.dll的错误版本。将SDL2.dll
复制到.exe
所在的目录。此外,从编译器的/bin
目录中,复制libgcc_s_seh-1.dll
,libstdc++-6.dll
,libwinpthread-1.dll
(名称可能略有不同,取决于您的MinGW发行版)。@HolyBlackCat非常感谢您,似乎已经修复了它!!:)
#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;
};