- Make A Windows Application In Dev C Fair Potent Memory
- Make A Windows Application In Dev C Fair Potent Amount
- Make A Windows Application In Dev C Fair Potent Weapon
- Make A Windows Application In Dev C Fair Potent Oil
Windows-based PCs. Build desktop applications that target PCs running Windows by using platforms including the Universal Windows Platform (UWP),.NET, and the Windows API (Win32). Like our Facebook Page: how to make graphics in dev c on Windows 10.Do graphics programming project using d.
Despite using Arch Linux for day-to-day computing I sometimes need to write some simple code in C++ for Windows.Switching operating systems back and forth is cumbersome so is compiling under virtual machine.
Windows port of GCC is named MinGW (Minimalistic GNU for Windows) and, quite surprisingly, it is available in repositories of major Linux distributions with wealth of open-source libraries cross-compiled for Windows platform.
Leveraging this tool, writing multi-platform software can be frictionless. It works well in IDE Clion too.For the demonstration I provide example repository which contains sample CMake project of DLL and Windows executables built by MinGW.
Installing MinGW toolchain
Under Arch Linux I recommend ownstuff unofficial repository. The compiler package is named mingw-w64
. You might try compiling it from AUR but it is a real pain. There are also lot of packages for various libraries; all package namesstart with mingw-w64-
. More detail on Arch Wiki.
MinGW is also available in official repository under Debian - meta package gcc-mingw-w64
. There are tonsof precompiled libraries; all having mingw
in package’s name. There is also Debian Wiki entry concerning this topic.
General configuration
The most important thing is to define the compiler executables and set CMAKE_SYSTEM_NAME
:
Then you simply define executable. This requires no further comments.
Make A Windows Application In Dev C Fair Potent Memory
To cross compile a dynamic loadable library you use add_library
, but for convenienceit’s better to set PREFIX
and SUFFIX
to empty strings. This way you can use the whole filename (with .dll
extension) as target name:
To link executable with aforementioned DLL, you add:
Using pkg-config
The common way of defining library compilation flags and directories under Unix is using pkg-config tool.This way your codebase is not dependent on the exact layout of directories of the distribution. Each libraryprovides .pc
file with the build parameters like header locations, compiler flags etc. Lot of packages compiled for MinGW also provide .pc
files,at least under Debian and Arch Linux.
For example, lets add zlib as dependency:
- Arch Linux:
aur/mingw-w64-zlib
package - Debian:
libz-mingw-w64-dev
Load PkgConfig
package and find zlib:
Make A Windows Application In Dev C Fair Potent Amount
Add dependencies to example executable:
Make A Windows Application In Dev C Fair Potent Weapon
Adding runtime libraries to Wine
When you try to run your freshly cross-compiled program under Wine, it probably will fail with the message like this:
It means that Wine cannot find runtime libraries which your program depends on. They are usually placed under /usr/i686-w64-mingw32/bin
. You’ll need to add this path to PATH
variable within Wine subsystem.
Edit file ~/.wine/system.reg
. This is the representation of Windows Registry under Wine. Find PATH
variable definition under [SystemCurrentControlSetControlSession ManagerEnvironment]
section.Append the library path as translated to Windows-like path: Z:usri686-w64-mingw32bin
so it looks like this:
Running with Wine under Clion
Make A Windows Application In Dev C Fair Potent Oil
Your CMake project should load in Clion without issues. Windows-specific headers like windows.h
are available. Build will configure itself automatically, but running the target will not. Fortunatelyyou can create Run/Debug configuration to run it under Wine - as shown in the picture: