CMake 和 MinGW w64 和 windows 系统库
CMake and MinGW w64 and windows system libraries
我开始学习CMake。我想使用 MinGW w64 使用 SDL2 库构建我的应用程序。我生成 Makefile 并使用 mingw32-make
构建我的应用程序。但是我的应用程序不会在没有任何消息的情况下执行(我的 OS 是 Windows 10)。首先,我认为我的应用程序看不到它的依赖项。我尝试使用 DependencyWalker 并找出下一步。我的应用程序看不到像
这样的库
API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL
API-MS-WIN-CORE-APPCOMPAT-L1-1-0.DLL
API-MS-WIN-CORE-APPCOMPAT-L1-1-1.DLL
API-MS-WIN-CORE-APPINIT-L1-1-0.DLL
和许多其他 API-MS-WIN
库。正如我所看到的,这个库位于 C:\Windows\System32
和 C:\Windows\SysWOW64
中。当我构建我的应用程序时,我 link 下一个库 -lmingw32 -lSDL2main -lSDL -mwindows
并且它 link 没有任何错误并且 DependencyWalker 没有说这有什么不好的。为什么我构建的应用程序没有看到 windows 个系统库?我的 PATH 环境有 System32
目录但没有 SysWOW64
。这可能是问题所在?
更新
我尝试将 SysWOW64 添加到 PATH 环境,但没有帮助。
添加 DependecyWalker 截图
one
two
three
更新 2
collapsed
哦,不!我犯了一个大错。我的问题不是 windows dll。我遵循 this 指南。我没有编写 windows 创建的部分代码。我的代码是
//Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>
//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
{
//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 );
}
}
根据示例编写代码时要小心:) 我通过添加我遗漏的部分来修复此问题。现在我的程序运行正常了。
我开始学习CMake。我想使用 MinGW w64 使用 SDL2 库构建我的应用程序。我生成 Makefile 并使用 mingw32-make
构建我的应用程序。但是我的应用程序不会在没有任何消息的情况下执行(我的 OS 是 Windows 10)。首先,我认为我的应用程序看不到它的依赖项。我尝试使用 DependencyWalker 并找出下一步。我的应用程序看不到像
API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL
API-MS-WIN-CORE-APPCOMPAT-L1-1-0.DLL
API-MS-WIN-CORE-APPCOMPAT-L1-1-1.DLL
API-MS-WIN-CORE-APPINIT-L1-1-0.DLL
和许多其他 API-MS-WIN
库。正如我所看到的,这个库位于 C:\Windows\System32
和 C:\Windows\SysWOW64
中。当我构建我的应用程序时,我 link 下一个库 -lmingw32 -lSDL2main -lSDL -mwindows
并且它 link 没有任何错误并且 DependencyWalker 没有说这有什么不好的。为什么我构建的应用程序没有看到 windows 个系统库?我的 PATH 环境有 System32
目录但没有 SysWOW64
。这可能是问题所在?
更新
我尝试将 SysWOW64 添加到 PATH 环境,但没有帮助。 添加 DependecyWalker 截图
one
two
three
更新 2
collapsed
哦,不!我犯了一个大错。我的问题不是 windows dll。我遵循 this 指南。我没有编写 windows 创建的部分代码。我的代码是
//Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>
//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
{
//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 );
}
}
根据示例编写代码时要小心:) 我通过添加我遗漏的部分来修复此问题。现在我的程序运行正常了。