【问题标题】:CMake and MinGW w64 and windows system librariesCMake 和 MinGW w64 和 windows 系统库
【发布时间】:2018-07-05 03:07:01
【问题描述】:

我开始学习 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 截图

one

two

three

更新 2

collapsed

【问题讨论】:

  • DependencyWalker 的完整输出是什么样的?请注意,所有 Windows 库(例如 kernel32.dll)都使用这些 API-MS,但很可能是过时的 walker 无缘无故地将它们标记为丢失。
  • 没有 SDL2 的简单 Hello World 应用程序可以工作吗?
  • @rustyx without SDL 我编译并成功运行了 Hello World 控制台应用程序。
  • 您应该发布折叠视图的屏幕截图(即第一级依赖项)并专注于 sdl 和 mingw 依赖项。所有来自系统库的 API-MS 都可以忽略。
  • @VVT 更新。据我所知mingw32 SDL2main SDL2 mwindows 有.a fromat,它们像静态库一样链接。 SDL2.dll 与.exe 位于一个文件夹中。

标签: c++ cmake sdl-2 mingw-w64


【解决方案1】:

哦,不!我犯了一个大错误。我的问题不是windows dll。我跟着this 指导。我没有编写创建窗口的部分代码。我的代码是

//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 );
    }
}

从示例中编写代码时要小心:) 我通过添加我错过的部分来解决这个问题。现在我的程序运行良好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-18
    • 1970-01-01
    • 1970-01-01
    • 2014-10-24
    • 1970-01-01
    • 2021-12-01
    相关资源
    最近更新 更多