Compiling WIN32 Code with GCC

I tried to compile C ++ WIN32 code with GCC through DevC ++ (MinGW GCC). He seams that he was unable to bind objects, and he did not give me a clear error message: "[PathToSource]> Error 1".

Tried the same with Eclipse (MinGW GCC) and compiled. However, not all resources are displayed, because I have a set of icons to compile as an application icon, which is loaded from resource files. I also launch a console window in the background when the application starts.

What is the reason for this? How can I make resource files compiled with code, and also avoid loading the console window in the background.

I was also wondering if there is a way to compile WIN32 code in Linux via GCC or a way to port it for the same compiler.

+4
source share
3 answers

Resource Files in Eclipse:

In the Project Build Steps , you must enter the command and the full path to the resource and its output file.

windres ../Resources/resource_file.rc -o ../Debug/resource_file.o 

In the parameters of the project tool in the linker settings, the path to the output file of the resource must be added so that the resources are associated with the executable file.

 ../Debug/resource_file.o 

Avoid the console window:

The linker flag should be specified only for the graphical interface.

 -mwindows 

In Eclipse :

Enter a flag in the Tool Settings project in the linker flags .

+1
source

Try compiling on the command line and see what happens.

for your resource file try this on the command line.

windres resource_file.rc -o resource_file.o and finally to create the g++ resource_file.o -o app.exe app.cpp

+4
source

I tried to compile some C ++ WIN32 code with GCC through DevC ++ (MinGW NKA). He seams that he was unable to bind objects, and this did not give me the error message: "[PathToSource]> Error 1".

Have you included the path to the Windows SDK? On my computer, this is:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64

(Note: I have Visual Studios installed on my computer)

Compile the program using the appropriate gcc library .

Tried the same with Eclipse (MinGW GCC) and it compiled. However, not all resources show how I have a set of icons to compile as an application icon, it is loaded from resource files. I also get a console window in the background, as I launch the application.

Check resource settings to see where Eclipse is linking to your Windows library.

What it is? How can I make resource files compiled with code, and also avoid loading the console window in the background.

Design your applications in Visual Studio. If you cannot afford Visual Studio and you are a hobby, consider Visual Studios Express .

I was also wondering if there is a way to compile WIN32 code in Linux via GCC, or is there a way to port it for the same compiler.

If you mean WINAPI, then no, not as much as I know. If you need compatibility, you should stick with the C ++ standard library.

There are, however, universal libraries that you might find useful:

+2
source

Source: https://habr.com/ru/post/1332989/


All Articles