Eclipse CDT using MinGW does not output in console - eclipse

I have a Windows 7 64-bit PC and I am trying to install a free C++ IDE, so I chose to install Eclipse Helios with CDT.
For g++, make and gdb I installed msys and mingw according to this tutorial:
http://wiki.wxwidgets.org/HowTo:_Install_MSYS_and_MinGW_for_use_with_Eclipse_CDT
The versions are:
make: GNU make 3.81
g++: 4.5.0
gdb: 7.1
So it should be compatible with my 64-bit CPU.
However when I try to run a very simple program with eclipse, I see nothing on the console. The source code is:
#include <iostream>
using namespace std;
int main()
{
int i;
cout << "Enter an integer: " << endl;
cin >> i;
cout << endl << "i is " << i << endl;
return 0;
}
The build is fine and when I launch the .exe with command (windows console) the behavior is as expected.
But with the Eclipse console I see nothing with run and with debug the output is just:
"Enter an integer: ", then when I type in a number and hit enter it does nothing.
Does anyone know how to fix this please?
Thanks,
Guillaume
PS: I use the toolchain "Linux GCC", with "MinGW GCC" I have nothing at all in the console.

This worked for me on 64-bit install of Eclipse on Windows 7 using MinGW:
Right-click on your project. Select "Properties".
Select the "Run/Debug Settings" Property on the left of the new window.
In the right window, click on your executable to highlight (ie - Test.exe) and click "Edit".
In the Environment tab, hit "New"
Name: PATH
Value: Path to your MinGW bin directory. (For me this was: C:\devcore\MinGW\bin)
Click "OK" on all windows to close down.
Try running again, it should print output to the screen.

You need to set up linker
I am using MinGW.
Follow below steps.
Goto Project > Properties > C/C++ Build > Settings > Tool Settings (Tab) > MinGW C++ Linker (Option) > Add Command (g++ -static-libgcc -static-libstdc++) (default command is only g++)

purlogic's solution works.
Instead to set that for every project, I found it can be set globally:
In Window -> Preferences-> C/C++ -> Build -> Environment
Add a variable for your compiler. e.g, I added:
MINGW, with value "C:\MinGW\bin"

This console bug has been noticed in 64-bit versions of eclipse:
http://www.eclipse.org/forums/index.php?t=msg&th=197552&start=0&S=2a2b64e1f1404705c0214976bd477428
A workaround is to install the 32-bit eclipse

I ran into the same problem, because of multiple gcc installations on one PC. But Greg's solution only worked partly for me.
In my case the flush was not done in the application explicitly. While C++ programs often use std::cout << ... << std::endl where the endl does a flush, my program used actual C-output such as the usual printf. The printf could be seen directly when starting the program in the cmd-window. However in eclipse console they were missing. Hence a
fflush(stdout);
after the printf did the thing for me. That could be an issue within the eclipse console implementation. I guess that's why fixing the Path did not work for some people here.
An alternative solution instead of setting the PATH within the "Run" settings is to start the whole eclipse using a batch file, which looks essentially like this:
set PATH=<mymingwlocation>\bin;%PATH%
start <myeclipselocation>\eclipse.exe
Then any run configuration would use the correct MingW location by default. That might also fix other problems that could arise from using the wrong gcc.

Have you tried to execute the eclipse.exe with administrator privileges ?? it worked for me !

Had this issue on 64-/32-bit eclipse Kepler CDT to work on a openCV/wxWidgets tool, Win7, using MinGW to build.
If anyone comes across this while having this issue and are working with openCV you will already know that there are many outdated openCV building/installing instructions all over the internet.
One I had was to go to Build Settings -> Linker -> Miscellaneous and inside of the Linker Flags text entry box, type in
-Wl,--subsystem,windows -mwindows
However, this disables cout from outputting to a command line terminal in windows.
Doing some more digging this looks intentional, apparently the -mwindows involves directing STDOUT away from a command line specifically to a GUI-like application.
Also, removing -mwindows and just leaving in -Wl,--subsystem,windows accomplishes the task of redirecting STDOUT anyway away from the command line all the same.
Now mind you, I haven't built up anything yet outside of a hello world program involving wxWidgets and openCV, so I am not at the point of doing a cout into a part of a GUI so I don't know if that functionality would now be broken or if it would print out to the GUI object, as well as a command line terminal.

Or set the linker option -static.
Works for me at least.

Add PATH variable (PATH="your MinGW/bin directory path") into your C++ project by Run -> Run Configurations ->in Environment Tab

Related

input not working while running in debug mode - eclipse cdt

Standard input works fine when I run my program, but doesn't work when in debugging mode, although output works fine as well.
I'm running Eclipse Photon (4.8) with CDT and for my toolchain I use gcc provided by Cygwin and I use gdb as my debugger.
Output when I run the program without debugging
Output when I run the program with debugging, mind the variable watches and the console
The Cygwin toolchain is detected automatically because it is present in the PATH environment variable, I also reset the workspace, but that didn't help.
UPDATE: If I put multiple cin lines one after another, the first cin will return a number different from that in the input and every consecutive cin will return a zero as a value.
UPDATE2: I found a workaround. If you use an external console (cmd) instead of the one in Eclipse, then it works. Image

compile qt code using gcc in ubuntu

I am new with Linux. I want to compile my code which written in qt creator using gcc in terminal. I don't know how should I do this task. the output will be called in Matlab. please give me information in this area. I search through the internet but i didn't find useful information to solve my problem.
Thanks
In QT Creator select "New project" -> Non-QT project -> plain C or C++ application, you can then edit your source in QT Creator, go to a Terminal & compile it using gcc or make your own makefile. From the Matlab instructions "The exclamation point character (!) sometimes called bang, is a shell escape. The character indicates that the rest of the input line is a command to the operating system. Use it to invoke utilities or call other executable programs without quitting MATLABĀ®".

How do I use Eclipse for Scheme development?

Has anyone succeeded in running and debugging Scheme with Eclipse?
I've tied several plug-ins (scheme 48, schemeway) and couldn't get them working. I'm not sure why they won't work; I downloaded an interpreter (kawa, mit-scheme) and tried to configure it in the plugin but nothing happened (except that mit-scheme threw some errors).
I know there is another way - Racket, but I prefer not to use another IDE. I work with many languages and I'd like to be able to use one IDE for all of them.
Any suggestions?
EDIT:
I tried to run the simplest .scm file (that has only (+ 1 1) in it). By configuration of the plug-ins I mean that I choose an external interpreter and then choose the kawa/mit-scheme interpreter exe file. When I choose kawa with schemeway it open a new window and waited for my input (I didn't have any input - JUST wanted to run the file...). When I did it with mit-scheme interpreter I got this error...
I am using linux-centOS 6.
Found the solution - here it is if someone else will encounter the same error:
There are 2 step when trying to work with Scheme 48 in Eclipse:
install the plugin - just follow http://s48.org/sdt/
install the interpreter - I finally found 2 that I can work with :
Scheme 48 (I use ubuntu so I typed scheme48 in the command line and it gave me the package that I need to install (I think it was
sudo apt-get install scheme48)). Then open the preferences in
Eclipse and go to scheme48->interpreter and check that the
command line is scheme48.
guile - I think that it is supported by gnu. It also the one I prefer. It had less errors and more understandable error output in the consul. Again, to install it I just typed guile in the command line and it gave me 3 versions. I installed 1.8. after installation I created a scheme project and a simple file. go to the preferences and changed the command line to "guile" and the working directory to the path of the project I just created. to load the file just search for the load file into interpreter button (or press Ctrl+F6).

use c++11 on mac os x mountain lion with eclipse (Juno or Kepler)

hey everyone I am just starting to use c++11, which I need for uni, a have a mac and I am familiarise with eclipse (I have both Juno or Kepler with CDT), but as much as I tried I can not run properly any c++11 features in eclipse or compile any code, there is someone that has been in my same position and please help me, seriously I already try all the previous threads about, but for my frustration i am still compiling everything on terminal and editing all in gedit with is not the most confortable way, by the way I have to compile with g++-4.7 as command not g++ meaning that still I have the old OS gnu,please someone just explain me step by step what to do I am terribly frustrated, I beg!!!!
ps. just clarify i install gcc 4.7 with homebrew but the path is different than the original (/usr/local/bin instead of the regular /usr/bin which I believe eclipse use and the reason I can't work with it, thank you for all guys)
Well after trying different things and expending tedious time fixing my issue I will answer my own question with the hope someone with my same needs will not experiment such annoying situation.
First as in a lot of forums remark and is well know the gcc compiler provided for the Mac OS is old and obsolete (more than 5 years old is a lot in computing terms), so first step to work with c++11 is to get a new version of the gcc.
There are two options with the packets common managers (homebrew and macports), I have to say that I was that frustrated that i tried both to see if was a problem of the version in the packet manager even thought should be the same, but for my surprise there is a small difference which later I will explain, which bring me to suggest use macport because with macports the eclipse will work as smooth as with the old c++ while with the installation with homebrew the compilation will be the same than the macport but eclipse will complain about the new grammar in the c++11 (eclipse will tell you that the resource couldn't be resolve, even do compile properly ).
The steps for this are assuming you have the command line already:
download the appropriate macports from the official web page(google it)
in terminal type the following commands
sudo port selfupdate
sudo port upgrade outdated
sudo port install -d gcc47
port select --list gcc
with this you have gcc and will show you which are the gcc installed in you mac now just missing select as defauld the new gcc, do it with.
- sudo port select gcc mp-gcc47
3 having install in my case eclipse kepler create a new C++ project, but instead to left everything standar do the next:
- in the wizard window select as toolchain the cross GCC as the toolchain(for example ni the executable Hello World c++ project), put a random name and next , following window press next now here in the window for the selection of the compiler give the path for the new gcc(the default is /opt/local/bin) as prefix leave it empty and press now the finish bottom.
4 Now go to project properties and in c/c++ build select settings and in the tool settings tab go to miscellaneous in cross g++ compiler and in other flags add -std=c++11.
5 by the last go to c/c++ general -> paths and symbols and select the tab symbols and in select the gnu c++ language and press add to type GXX_EXPERIMENTAL_CXX0X as name just that and press ok.
Now just press apply and ok, after that your mac should be running c++11 in eclipse.
Hope works for you as for me see you around guys.
Note probably you will be to configurate the run but it is more simpler than you thing just go to run -> run configurations and double click in c/c++ application now almost everything is generate for you just you have to fill up the first label with the path to the out put of the compiler (I asumme that you already build the project which will generate the executable file ) normally that file is in the debug folder of the project with the same name than the file compiled n does all.
have a good one guys.

Difference in Run & Debugg mode in Eclipse for Perl

I am using Eclipse along with EPIC plug in and pad walker for running my Perl project.
I am facing a strange issue
If I "Run" the project, the system fails and exits Perl without any error message.
But if I "Debug" the project and then give "Run" the same Perl scripts work fine as expected.
Could anyone let me know the difference in the two mode ("Direct Run" & "Debug & Run")?
Found it in the EPIC source code: EPIC adds the "-d" command line option for the debug target. It does some interesting things with the stdin/stdout too to remotely control the debugger. So maybe there's some side effect there? Can you share the error message?