c++ - CMake 和 MinGW w64 和 windows 系统库
问题描述
我开始学习 CMake。我想使用 MinGW w64 使用 SDL2 库构建我的应用程序。我生成 Makefile 并mingw32-make
用于构建我的应用程序。但是我的应用程序在没有任何消息的情况下无法执行(我的操作系统是 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
. 当我构建我的应用程序时,我链接了下一个库-lmingw32 -lSDL2main -lSDL -mwindows
,并且链接没有任何错误,并且DependencyWalker对此并没有说什么不好。为什么我构建的应用程序没有看到 Windows 系统库?我的 PATH 环境有System32
目录但没有SysWOW64
. 也许这有问题?
更新
我尝试添加到 PATH 环境 SysWOW64 并没有帮助。添加DependecyWalker截图
更新 2
解决方案
不好了!我犯了一个大错误。我的问题不是windows dll。我遵循本指南。我没有编写创建窗口的部分代码。我的代码是
//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 );
}
}
从示例中编写代码时要小心:) 我通过添加我错过的部分来解决这个问题。现在我的程序运行良好。
推荐阅读
- java - 为什么@resource 可以找到所有类都实现了一个接口并将它们作为列表注入
- java - 在 JBoss 上运行的 AKS 应用程序的 IntelliJ 中调试无故断开连接
- python - 如何获取第th 个元素
直接排列序列(没有任何递归)? - reporting-services - SSRS用HTML表格实现mailto功能
- javascript - 在所有 axios 请求完成后运行一段 vuejs 代码
- amazon-web-services - 用于获取 ELB 的 Route 53 记录集的 AWS CLI 命令
- oracle - 带有用户创建记录的关联数组的 PLS-00306 错误
- python - PySide2 QListView QTableView 同步问题
- python - python - 如何在出现密钥错误时在python中连接redis服务器?
- http - 如何取消在 Flutter 中使用 http.MultipartRequest() 发送的正在进行的文件上传?