- 下载xmake, 并安装.(下载的是安装文件,直接安装到Windows下, 重启了一下电脑,否则环境变量不生效).
下载地址 : https://github.com/xmake-io/xmake/releases/tag/v2.5.2 - 打开命令行,输入xmake --help, 有结果显示, 说明安装成功了.
- 下载imgui源码 : https://github.com/ocornut/imgui
- 新建一个目录,在这个目录下执行xmake create -l c++ -P ./imguiDemo, 这样就创建了一个工程.
- 将imgui/src下的源码拷到imguiDemo/src下。
- 我这边是运行的dx11的例子. 将imgui/src/backends下的imgui_impl_dx11.*和imgui_impl_win32.*拷到imguiDemo/src下.
- 将example/example_sdl_directx11下的main.cpp拷贝到imguiDemo/src下。
- 执行xmake进行编译,会出现以下错误:
error: main.cpp.obj : error LNK2019: 无法解析的外部符号 D3D11CreateDeviceAndSwapChain,该符号在函数 "bool __cdecl CreateDeviceD3D(struct HWND__ *)" (?CreateDeviceD3D@@YA_NPEAUHWND__@@@Z) 中被引用
解决这个问题方法是: 打开main.cpp文件,在#include下边增加 #pragma comment ( lib, "D3D11.lib") , - 执行xmake进行编译, 此时如果没有意外会编译连接成功。
- 执行xmake run imguiDemo.ext ,程序会正常运行。
Windows下XMake编译imgui成功之DX11
最新推荐文章于 2024-05-21 19:42:00 发布