'How to compile imgui source files using gcc
How do you compile imgui source files with gcc
According to build_win32 in one of the examples in the repo
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
@set OUT_DIR=Debug
@set OUT_EXE=example_win32_directx11
@set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include"
@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
mkdir %OUT_DIR%
cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
the first three lines are not important since they define the output directory and the output executable, next is the INCLUDES which I included in my Makefile, next is the source files which I also added but for some reason does not work as expected
CC = g++
FILES = main.cpp C:\\Users\\test\\Desktop\\imgui\\backend\\imgui_impl_dx11.cpp C:\\Users\\test\\Desktop\\imgui\\backend\\imgui_impl_win32.cpp C:\\Users\\test\\Desktop\\imgui\\backend\\imgui*.cpp
INCLUDES = -I C:\\Users\\test\\Desktop\\my-project\\Include -ld3d11 -ld3dcompiler
build: $(FILES)
$(CC) $(FILES) $(INCLUDES)
The Includes folder contains all the header files from the folder backend
this is what I get when I run the command make
make: *** No rule to make target 'C:\\Users\\test\\Desktop\\imgui\\backend\\imgui_impl_dx11.cpp', needed by 'build'. Stop.
why do I get this error?
Solution 1:[1]
This answer is more of a thank you to HolyBlackCat for helping
I used MSYS2shell to compile with MINGW64 environment
after cloning the repo to the Desktop I used
export $IMGUI_DIR=C:/Users/test/Desktop/imgui
this makes the final command shorter and gives the variable IMGUI_DIR the path of the imgui repo
next
we run the command
g++ main.cpp $IMGUI_DIR/backends/imgui_impl_dx11.cpp $IMGUI_DIR/backends/imgui_impl_win32.cpp $IMGUI_DIR/imgui*.cpp -I $IMGUI_DIR -I $IMGUI_DIR/backends -ld3d11 -ld3dcompiler -lgdi32 -ldwmapi
where
main.cpp is your code (the example to be used)
$IMGUI_DIR/imgui.cpp includes all source files of imgui
-I $IMGUI_DIR includes header files in the imgui folder
-I $IMGUI_DIR/backends includes backend header files
-ld3d11 -ld3dcompiler -lgdi32 -ldwmapi links windows libraries needed for
imgui to work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | netrunner |
