I have a curses application. It previously compiled using mingw from
batch files, this program is stable, has been working for years.
Recently, it compiles as 32-bit under msys2 with shell scripts.
When I try to start it from a mintty window, it says:
When mintty starts, it says xterm-256color under "Options / Terminal
/ Type". I have tried changing to the other options (xterm, etc.),
applying, exiting mintty, restarting, running export TERM=whatever. Each
time, I get the same type error message, such as:
In other words, if I can create a small test C program that crashes, along with how I compile and run it, you can try reproducing and investigating the error?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
lemur:1:/home/ehdp/vn/util/test$catncurses-1.c/* Figure out msys2 crash */#include<stdio.h>#include<curses.h>intmain(){initscr();/* Start curses mode */printw("Hello World !!!");/* Print Hello World */refresh();/* Print it on to the real screen */getch();/* Wait for user input */endwin();/* End curses mode */return0;}lemur:1:/home/ehdp/vn$echo$PATH/mingw32/bin:/usr/bin:/bin:/c/Program Files/Common Files/Microsoft Shared/Windows Live:/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files (x86)/Intel/OpenCL SDK/3.0/bin/x86:/c/Program Files (x86)/Intel/OpenCL SDK/3.0/bin/x64:/d/Program Files (x86)/Putty:/c/Program Files (x86)/Windows Live/Shared:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/ehdp/vn/ro/vn-exes/vcu1/:/home/ehdp/vn/ssdir/backups:/home/ehdp/vn/ssdir/compile:/home/ehdp/vn/ssdir/maintain:/home/ehdp/vn/ssdir/transfer:.
When I tried running under Windows command window, it first complained about not finding libwinpthread-1.dll - I copied a.exe to same (non-system) directory as the DLL, and a.exe ran fine. I went back to mingw64 and mingw32 windows, recompiled the test case, copied a.exe to the directory with the dll, and the error message / crash still happened. I don't understand what's going on with the libwinpthread-1.dll under windows, but I think the "error opening terminal" error is not related. However, in case helpful:
$ file *.dll
libwinpthread-1.dll: PE32 executable (DLL)(console) Intel 80386(stripped to external PDB), for MS Windows
Please at least let me know if you can reproduce the problem.
Daniel
PS - When I compose this, the first hash-include is ENORMOUS, and the sourceforge decides it want italics for the little comment. Is there a way to tell the editor "text only, no fixin' up"? Anyway, the test case is exactly from the web site link shown on first line, in case any question.
Last edit: David Macek 2015-11-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ad formatting: You should be able to use three backqoutes on a separate line to start a code block and the same to end it, but it seems to not work here correctly. When clicking on the icon for code in the formatting bar, it surrounds the text with four tildes on separate lines, which does work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A potential problem is that you're combining ncurses headers for msys2 and ncurses library for mingw-w64. The actual problem is that you're building an ncurses application for native Windows, which means you should be running it in a regular console window, not mintty.
I don't know enough about ncurses to propose a solution for running these things in mintty. Not even winpty seems to help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To test this further:
- I installed pdcurses (windows curses library) to under the msys2 root.
- Then, I compiled the test case program using pdcurses.
- The exe run fine under Windows command prompt window.
- Again, crashes under mintty, but this time reports a different problem:
$ echo$MSYSTEM
MINGW32
$ echo$TERM
xterm-256color
$ cat ncurses-1.c
/* Figure out msys2 crash */
#include <stdio.h>#include <curses.h>
int main(){
initscr(); /* Start curses mode */
printw("Hello World !!!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */
return0;}
$ ./temp.sh
$ ./a.exe
Redirection is not supported.
Different values for TERM did not change the error message.
http://savannah.gnu.org/bugs/?32077
seems to be saying that others have noticed this same problem, and there could be a way to run a windows application under mintty. However, it's a little hard to figure out.
If anyone has any ideas, let me know. The links suggest there may be some way a Windows curses program compiled under msys2 can run under mintty. I wish I knew for sure, yes or no. BTW, the reason I am interested in running under msys2 is to run gdb. Of course, I could also do that under the Windows command prompt. Just seems msys2 is a better development / testing environment.
The formatting looks OK with the preview. Cross my fingers and click "post".
Thanks,
Daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is a ticket on the mintty project site: https://github.com/mintty/mintty/issues/56
It could contain some information about running native terminal programs inside mintty.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I get a similar result running ldd on the vim running under msys2. So the idea that mintty "can't run something compiled under curses" doesn't seem to be true.
In addition, I can run the msys2 mc and vim programs under the windows cmd.exe (Command Prompt) window fine, I detect no problem. That's what I want to do. It seems to work with vim and mc.
If vim and mc are NOT using curses, then what are they using for screen control?
So a curses program can (apparently) be compiled under msys2 and run under either mintty or cmd.exe window. I'm just compiling it wrong, that's all. Under MINGW32 window:
Could someone point me to how to compile it "right"? For example, how are mc and vim compiled? It would be nice if there was a simple example of how to compile a curses program correctly under msys2, so it runs under either msys2 or cmd.exe window. I would be willing to help write the example, if I had any idea of the "right" way.
Any input appreciated.
Thanks,
Daniel
Last edit: DanAaronGoldman 2015-12-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In a recent mailing list post, I saw winpty (was not aware of it before) mentioned. It seems to at least partially fix the curses problem.
The curses program, plus simple test curses programs I had presented, previously produced error messages like the following and crashed:
$ txu1-tpl-eg1.exe
Redirection is not supported.
$
With "winpty txu1-tpl-eg1.exe" the program at least starts up, looks perfect visually. The program responds to keyboard commands (eg, q to quit). Pressing ENTER goes to a submenu, and that works.
Unfortunately, the arrow keys, PgUp, PgDn, Home, End keys don't work. They work correctly when the program runs under a windows 7 command window. Does anybody have a clue why the arrow keys do not work for running a pdcurses program under mintty / winpty?
I wanted to thank Greg Jung for sending a very helpful response. It might benefit some others.
Run "C:\msys64\usr\bin\bash.exe --login -i" from within the windows 7 command prompt ("dos shell") and get a bash prompt. Then run the curses (compiled with pdcurses) program with "./txu1-tpl-eg1.exe" - it runs perfectly! Arrow keys work, everything looks / functions perfectly.
Next, make a copy of the command prompt desktop icon, change the target to the command line given above, it works perfectly.
I'm still confused about the difference between 1) mintty, 2) winpty from within mintty, 3) bash.exe from within dos window, and 4) dos window itself. For example, I notice that mc runs poorly under the bash.exe environment. Arrow keys don't work, colors get messed up, it is slow. Oddly, mc (same exe) runs perfectly when run directly from dos shell.
Obviously, I don't really understand what's going on. It would be nice if someone who understands more about this could post some advice, related to different options for compiling and running curses applications under msys2.
Anyway, at least the bash.exe option is good progress.
Daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey !
I too have been blocked by this problem with Ncurses and Mintty.
however with the windows console works well.
So to settle this problem,
as stated in the documentation: http://linux.die.net/man/3/ncurses
Global variables such as $TERM and $TERMINFO help ensure the "terminal description".
So it only remains to prepare Minnty with a small scipt kind of preparation:
I have a curses application. It previously compiled using mingw from
batch files, this program is stable, has been working for years.
Recently, it compiles as 32-bit under msys2 with shell scripts.
When I try to start it from a mintty window, it says:
When mintty starts, it says xterm-256color under "Options / Terminal
/ Type". I have tried changing to the other options (xterm, etc.),
applying, exiting mintty, restarting, running export TERM=whatever. Each
time, I get the same type error message, such as:
The exact same txu1-tpl-eg1.exe application starts up and runs fine from a
windows 7 "Command Prompt" (DOS Window).
I installed and ran mc (midnight commander), which seems to also
use ncurses. It runs perfectly uner mintty here, if that is any help.
I looked around the internet, could not find clues. Any help appreciated.
Thanks,
Daniel
Last edit: David Macek 2015-11-17
I found !
Please read my last post : https://sourceforge.net/p/msys2/discussion/general/thread/f81f0b97/#e1ad
Last edit: Logicae 2016-06-02
If you can make a minimal testcase we'd be able to investigate this for you.
In other words, if I can create a small test C program that crashes, along with how I compile and run it, you can try reproducing and investigating the error?
Yeah.
It was pretty easy to make a test case:
http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html
When I tried running under Windows command window, it first complained about not finding libwinpthread-1.dll - I copied a.exe to same (non-system) directory as the DLL, and a.exe ran fine. I went back to mingw64 and mingw32 windows, recompiled the test case, copied a.exe to the directory with the dll, and the error message / crash still happened. I don't understand what's going on with the libwinpthread-1.dll under windows, but I think the "error opening terminal" error is not related. However, in case helpful:
Please at least let me know if you can reproduce the problem.
Daniel
PS - When I compose this, the first hash-include is ENORMOUS, and the sourceforge decides it want italics for the little comment. Is there a way to tell the editor "text only, no fixin' up"? Anyway, the test case is exactly from the web site link shown on first line, in case any question.
Last edit: David Macek 2015-11-17
ad formatting: You should be able to use three backqoutes on a separate line to start a code block and the same to end it, but it seems to not work here correctly. When clicking on the icon for code in the formatting bar, it surrounds the text with four tildes on separate lines, which does work.
A potential problem is that you're combining ncurses headers for
msys2
and ncurses library formingw-w64
. The actual problem is that you're building an ncurses application for native Windows, which means you should be running it in a regular console window, not mintty.I don't know enough about ncurses to propose a solution for running these things in mintty. Not even winpty seems to help.
To test this further:
- I installed pdcurses (windows curses library) to under the msys2 root.
- Then, I compiled the test case program using pdcurses.
- The exe run fine under Windows command prompt window.
- Again, crashes under mintty, but this time reports a different problem:
$ cat temp.sh gcc ncurses-1.c -I d:/msys64/var/local/pdc34dll/ \ -L d:/msys64/var/local/pdc34dll/ -lpdcurses
Different values for TERM did not change the error message.
http://savannah.gnu.org/bugs/?32077
seems to be saying that others have noticed this same problem, and there could be a way to run a windows application under mintty. However, it's a little hard to figure out.
http://neolit123.blogspot.com/2011/01/re-packing-gnu-nano-225-for-use-on.html
seems kind of a similar story.
https://github.com/mcandre/nano-win/tree/master/bin
is more information. Also, a little hard to interpret. As with above links, references cygwin.
If anyone has any ideas, let me know. The links suggest there may be some way a Windows curses program compiled under msys2 can run under mintty. I wish I knew for sure, yes or no. BTW, the reason I am interested in running under msys2 is to run gdb. Of course, I could also do that under the Windows command prompt. Just seems msys2 is a better development / testing environment.
The formatting looks OK with the preview. Cross my fingers and click "post".
Thanks,
Daniel
Here is a ticket on the mintty project site: https://github.com/mintty/mintty/issues/56
It could contain some information about running native terminal programs inside mintty.
Thanks. Hard to understand the ticket on the mintty site.
https://github.com/mintty/mintty/issues/240 - is a separate mintty ticket I found that specifically references pdcurses and basically says it does not work under mintty.
However, mc (midnight commander) runs fine under msys2 mintty. It seems to use ncurses (does it?).
I get a similar result running ldd on the vim running under msys2. So the idea that mintty "can't run something compiled under curses" doesn't seem to be true.
In addition, I can run the msys2 mc and vim programs under the windows cmd.exe (Command Prompt) window fine, I detect no problem. That's what I want to do. It seems to work with vim and mc.
If vim and mc are NOT using curses, then what are they using for screen control?
So a curses program can (apparently) be compiled under msys2 and run under either mintty or cmd.exe window. I'm just compiling it wrong, that's all. Under MINGW32 window:
Could someone point me to how to compile it "right"? For example, how are mc and vim compiled? It would be nice if there was a simple example of how to compile a curses program correctly under msys2, so it runs under either msys2 or cmd.exe window. I would be willing to help write the example, if I had any idea of the "right" way.
Any input appreciated.
Thanks,
Daniel
Last edit: DanAaronGoldman 2015-12-21
In a recent mailing list post, I saw winpty (was not aware of it before) mentioned. It seems to at least partially fix the curses problem.
The curses program, plus simple test curses programs I had presented, previously produced error messages like the following and crashed:
With "winpty txu1-tpl-eg1.exe" the program at least starts up, looks perfect visually. The program responds to keyboard commands (eg, q to quit). Pressing ENTER goes to a submenu, and that works.
Unfortunately, the arrow keys, PgUp, PgDn, Home, End keys don't work. They work correctly when the program runs under a windows 7 command window. Does anybody have a clue why the arrow keys do not work for running a pdcurses program under mintty / winpty?
Daniel
PS - http://blog.toonormal.com/2012/11/17/gcc-msys-mintty-pdcurses-winpty-and-good-times-in-the-shell/ is a related post I found, in case helpful for anyone.
I wanted to thank Greg Jung for sending a very helpful response. It might benefit some others.
Run "C:\msys64\usr\bin\bash.exe --login -i" from within the windows 7 command prompt ("dos shell") and get a bash prompt. Then run the curses (compiled with pdcurses) program with "./txu1-tpl-eg1.exe" - it runs perfectly! Arrow keys work, everything looks / functions perfectly.
Next, make a copy of the command prompt desktop icon, change the target to the command line given above, it works perfectly.
I'm still confused about the difference between 1) mintty, 2) winpty from within mintty, 3) bash.exe from within dos window, and 4) dos window itself. For example, I notice that mc runs poorly under the bash.exe environment. Arrow keys don't work, colors get messed up, it is slow. Oddly, mc (same exe) runs perfectly when run directly from dos shell.
Obviously, I don't really understand what's going on. It would be nice if someone who understands more about this could post some advice, related to different options for compiling and running curses applications under msys2.
Anyway, at least the bash.exe option is good progress.
Daniel
Hey !
I too have been blocked by this problem with Ncurses and Mintty.
however with the windows console works well.
So to settle this problem,
as stated in the documentation: http://linux.die.net/man/3/ncurses
Global variables such as $TERM and $TERMINFO help ensure the "terminal description".
So it only remains to prepare Minnty with a small scipt kind of preparation:
Important Note the compatibility with
$TERM = xterm
is still on top, so I continued my research ...Voila, here.
Last edit: Logicae 2016-06-02