简体   繁体   中英

Error when compiling olcPixelGameEngine with g++

I'm trying to use OneLoneCoder 's olcPixelGameEngine , but when I try to compile my file ( g++ -o YourProgName YourSource.cpp -lX11 -lGL -lpthread -lpng -lstdc++fs -std=c++17 ), I get the error:

fatal error: dwmapi.h: No such file or directory

I use g++ 9.2 with MinGW. Where do I find dwmapi.h ?

2 problems I'm seeing immediately

First, you're not using the proper build command for MinGW, you're using the Linux GCC build command, which is requiring libraries that don't exist in MinGW.

Instead try something like this:

g++ -o olcExampleProgram.exe olcExampleProgram.cpp -luser32 -lgdi32 -lopengl32 -lgdiplus -lShlwapi -ldwmapi -lstdc++fs -static -std=c++17

Second, you're likely using a bad version of MinGW.. Long story short, not all MinGW are created equal and currently, the best version (and the one that has been tested to compile PGE applications) is the version provided by MSYS2.

If you want you can check the PixelGameEngine WIKI page on the subject.

https://github.com/OneLoneCoder/olcPixelGameEngine/wiki/Compiling-on-Windows-with-Other-Compilers

That's the Linux build command, look at this instead: https://community.onelonecoder.com/2020/05/08/lets-make-an-olcpixelgameengine-application-using-mingw/ Also, next time you probably get quicker help on the discord server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM