Windows build with -mwindows flag no executable - c++

I had problems building a program I'm working on in C++ because MinGW files and Windows SDK file were conflicting and I found the solution by adding the -mwindows flag for the linker to the build options. This works: now I can build the project without errors.
But now the compiler doesn't output any executable file (.exe).
My question is: why? And what exactly the -mwindows does?
Edit: The output of the build phase is reported in a text file in this Dropbox folder (I couldn't copy it here because it's more than 2800 lines): https://www.dropbox.com/sh/1ud85a3fktb62v6/AAB3L8Vp5VcKPJqCPyOXtzdca?dl=0
I already tried to create a new 'Hello World' project and build it: the executable file is created and I can run it, so I think the cause of my problem is that flag and not a particular setting on my IDE (CLion).

Related

Missing .qmake.stash file

Who creates .qmake.stash file? When is it created?
I've been working with Qt in Visual Studio creating Windows applications for some years now but never had to care about this file. But now I have set up a cross compilation in Visual Studio using WSL 1 in order to build my application for Linux on arm64.
I'm able to build all projects in my VS solution on my development computer. Now I'm trying to setup this cross compilation system on another PC. The first project of this solution could be built without a problem, but the second one failed with
error : qmake: Project ERROR: Cannot run compiler 'aarch64....'
error : qmake: Maybe you forgot to setup the environment?
error : qmake: Error creating Makefile
After many hours of investigation comparing project files and configurations I was able to find the reason: qmake didn't find the file .qmake.stash when it should create the Makefile.
The working project has a .qmake.stash file in the intermediate output path $(IntDir) /obj//<vs_configuration>, e.g. myproject/obj/x64/RelArm64.
The failing project doesn't have this file in its $(IntDir).
If I manually copy this file from the working project to the other project, it works, too.
Who should have placed this file to $(IntDir) before executing qmake?
My qmake.stash file in the working project is quite old. So it seems as if it isn't generated during every build process.

CPP codes linking in VScode with Mingw-w64 in Windows 10

I'm learning C++ with VScode with Mingw-w64 in Windows 10.
Today, I watched how to make header files and build the separated codes in Visual Studio 2019.
I wanted to implement this process in Visual Studio Code editor, but I met linking error.
My naive solution is like
~$ g++ -c .\main.cpp .\add.cpp
~$ g++ .\main.o .\add.o -o test.exe
First, compiling the source codes into object files.
Second, linking those object files to an execution file.
It works anyway, but when I tried to run the debugging mode, it doesn't work.
I think I need to edit launch.json file, but I have no idea...
The following images are about my situation.
How can I build those separated codes at once?
In this time, I just described the path of the definition code into 'tasks.json' file.
After then, built the main code again, so that it worked.

Dev-c++ compilation and linking problems

I've inherited a dll file and its source code and I need to rebuild it. The dll file exports functions that are needed in another application. It was originally made using an older version of dev-c++ (probably a few years back). When I try to build it, the compilation process goes fine and the object files are created, but I get an error during the linking process. Here's an excerpt from the output of the compile log.
g++.exe: error: unrecognized command line option '--no-export-all'
g++.exe: error: unrecognized command line option '--add-stdcall-alias'
I am looking for a solution to this problem, solution meaning being able to rebuild the dll. I do not have contact with the creator of the source code. Any suggestions, ideas or answers would be much appreciated. I am using dev-c++ 5.11 and using the TDM-GCC 4.9.2 32-bit compiler.

How to configure NetBeans to statically link MinGW C++ libraries?

I have built an executable file (.exe), but when I run it, a window pops up which says
The program can't start because libgcc_s_dw2-1.dll is missing from your computer. Try reinstalling the program to fix this problem.
Can I configure Netbeans to include that file into the .exe file?
You can.
In Netbeans, right-click on the project node in the Projects window, then click Properties. Click the Build > Linker node. Under the Compilation Line category, there is a field named Additional options. Now enter the following line:
-static-libgcc -static-libstdc++
Click OK. Now it works.
Notice that your file is much larger than if it were compiled without the library. If you are not (yet) planning to distribute the executable, then maybe it's a better option to set the PATH environment variable. See The program can't start because libgcc_s_dw2-1.dll is missing for more details.

Set up Eclipse C++ compiler without auto-install or altering System Path on Windows

I am trying to install a C++ compiler on Eclipse without altering the Path variables as I can't, the machine has limited rights. Eclipse obviously runs fine, it's the build that doesn't, it complains about.
The first thing I noticed was a warning that said "Unresolved inclusion" for the libary file stdio.h
I added the path variable inside Eclipse's "Windows > Preferences > C/C++ > Environment" with a new environment variable named "Path" with a path to my minGW/bin folder but to no avail. I also tried setting it to "Replace the native environment variable with specified one" but also no change.
The build errors out saying:
**** WARNING: The "Default" Configuration may not build ****
**** because it uses the "MinGW GCC" ****
**** tool-chain that is unsupported on this system. ****
and then
(Cannot run program "make": Launching failed)
And of course no more. It's a simple Hello World test, so the code shouldn't be an issue. I can see the includes under a folder in the "Includes" area that Eclipse generates (D:\MinGW\binutils\lib) but clicking on them in the Outline tab of Eclipse brings up the error "No include files were found that matched that name".
It looks like you're trying to build a simple hello world program using Eclipse/CDT and a development environment and using mingw as the compiler tool chain. I was able to get this working just now without modifying my system path environment variable. This is what I did:
I already had Eclipse 3.5 (Galileo) installed with CDT
Installed MinGW to C:\MinGW (I assume you already had this done). Make sure the mingw-make component is installed (it's not installed by default, I had to check the box to install this component).
Create a new empty makefile project, add main.c, write hello world code (as you say this isn't the problem so I'm skipping detail here), add a new file called "makefile" and fill it in.
Contents of my main.c file
#include
int main()
{
printf("Hello World!");
return 0;
}
Contents of my makefile:
all:
gcc -o HelloWorld.exe main.c
Open the project properties; Under C/C++ Build uncheck the "use default build command" and change the build command to "mingw32-make".
Under "C/C++ Build/Environment" add a new PATH variable with C:\Mingw\bin in the path
Under "C/C++ General/Paths and Symbols" add C:\mingw\include as an include path.
After doing this, my project built successfully and produced a HelloWorld.exe exectuable in my project.
Another option that doesn't require adding a PATH variable to the system or project properties, or adding the include path to the project properties is to simply gives full path info to the commands in the makefile. For small projects this is manageable. Here's an example makefile:
Contents of makefile:
all:
c:\mingw\bin\gcc -o HelloWorld.exe -I c:\mingw\include main.c
Of course you'll also have to change the build command from simply "mingw32-make" to "C:\mingw\bin\mingw32-make" as well.
Another downside of this approach is that the CDT code parser will not be able to locate include files so you'll have warning in the editor to that effect.