PDA

View Full Version : How to invoke Mingw Compiler?



parulkalra14
14th January 2014, 10:42
I have two projects X and Y. X is CodeEditor with Command Prompt and Y is Mingw Compiler. I want the result of C and C++ program (that are written on CodeEditor) will be shown on Command Prompt. Basically I want my CodeEditor will invoke C or C++ compiler (mingw) and output of the program(C or C++) will shown at Command Prompt. So I have two Queries:
1. How CodeEditor will invoke Mingw?
2. How to link CodeEditor with Command Prompt?

Any ideas to understand these two invoking and linking queries?

stampede
14th January 2014, 10:49
Are you aaditya190 ? You are posting very similar (http://www.qtcentre.org/threads/57605-Linking-a-plaintextedit-to-the-gcc-compiler) questions (http://www.qtcentre.org/threads/57147-Linking-textedit-to-the-compiler)... Btw. your question is answered in linked threads.

parulkalra14
14th January 2014, 11:39
Yes We both are Teammates that's why most of the times our questions are very much similar.Yes i already read these linked threads but i am new to qt creator, I am not able to understand these thread well. Can anyone ellaborate the concept of invoking a compiler and linking compiler both with CodeEditor and Command Prompt ?

wysota
14th January 2014, 13:08
Yes We both are Teammates that's why most of the times our questions are very much similar.

So why don't you continue your friend's threads instead of starting new ones on the same subject?

ChrisW67
15th January 2014, 04:49
I am not able to understand these thread well.
If you are not able to read and understand the friendly manual about QProcess (as indicated in the linked threads) then you will be unable to complete the task before you. Read on to understand why.

Can anyone ellaborate the concept of invoking a compiler and linking compiler

Send text to be compiled to a file (QFile)
Invoke compiler/linker with appropriate command line arguments using QProcess, or write a Makefile to file and invoke make with QProcess. Capture output from QProcess if you want to display the compiler output.
If you want to capture the output of running the compiled program (if there is one after compilation and linking) then run the compiled program with QProcess and capture output from QProcess.


The code snippets in the QProcess manual are all you need to know to to launch a compiler, linker, make utility, or other arbitrary program. The manual provides the information you need to read any output from those programs.

Nobody here is going to give you and your teammate a copy and paste solution to the problem of "develop a simple IDE" (whether for school or work). It is likely that you will receive answers to specific questions if you have them as a result of trying things after reading the friendly manual.

As for the specific question in the thread title, "How to invoke Mingw Compiler?". The answer is, execute "gcc" or "g++" in a suitable environment and with suitable arguments.

aaditya190
16th January 2014, 08:11
@Chrisw67 and @wysota, Thank you very much for your help. We have created a process that runs a batch file, and compiles the program (using g++) in the textedit and gives output. We are using plaintextEdit for both input and output. The problem we are facing is if we are using "\b" in a C-program, it doesn't work instead displays bullets in place of "\b". Can you suggest us some means so that "\b" can work??

wysota
16th January 2014, 08:22
What is "\b"? How should it "work"? What does it have to do to invoking MinGW compiler?

aaditya190
16th January 2014, 08:37
@wysota, It has nothing to do with invoking. I am continuing the same thread instead of beginning a new one. "\b" is used for backspaces in a C-program. When the output containing "\b" is written to a txt file, "\b" displays bullets instead of backspaces. Can you help me out with this?

wysota
16th January 2014, 09:38
@wysota, It has nothing to do with invoking. I am continuing the same thread instead of beginning a new one.
So start a new one if you have a different problem. This thread is not called "All problems of aaditya190".


"\b" is used for backspaces in a C-program.
Did you remember to escape the backslash


When the output containing "\b" is written to a txt file, "\b" displays bullets instead of backspaces.
It is the program you use for displaying the file that does that, not "the compiler".