abishekvashok / cmatrix

Terminal based "The Matrix" like implementation
GNU General Public License v3.0
4.02k stars 417 forks source link

Error compiling on Cygwin #40

Open thorstenkampe opened 6 years ago

thorstenkampe commented 6 years ago
make[1]: Entering directory '/cygdrive/c/Users/thorsten/Desktop/cmatrix-master'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT cmatrix.o -MD -MP -MF .deps/cmatrix.Tpo -c -o cmatrix.o cmatrix.c
cmatrix.c: In function 'resize_screen':
cmatrix.c:253:10: error: lvalue required as left operand of assignment
     COLS = win.ws_col;
          ^
cmatrix.c:254:11: error: lvalue required as left operand of assignment
     LINES = win.ws_row;
           ^
cmatrix.c:257:15: error: lvalue required as left operand of assignment
         LINES = 10;
               ^
cmatrix.c:260:14: error: lvalue required as left operand of assignment
         COLS = 10;
              ^
make[1]: *** [Makefile:425: cmatrix.o] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/thorsten/Desktop/cmatrix-master'
make: *** [Makefile:315: all] Error 2

GCC is version 6.4.0. Do you need more information?

abishekvashok commented 6 years ago

GCC is version 6.4.0. Do you need more information?

Nope. Thanks for testing. :)

abishekvashok commented 6 years ago

Since this occurs on Cygwin can someone of the community please do this? I am not having the tool chain setup for debugging the same.

thunderactual commented 6 years ago

Bump. I am also getting the same error!

abishekvashok commented 6 years ago

@thunderactual mind helping :) ?

rubenkr commented 6 years ago

Same error here - what can I do to fix this?

➜ cmatrix git:(master) make make all-am make[1]: Entering directory '/home/rk/cmatrix' gcc -DHAVE_CONFIG_H -I. -g -O2 -MT cmatrix.o -MD -MP -MF .deps/cmatrix.Tpo - c -o cmatrix.o cmatrix.c cmatrix.c: In function ‘resize_screen’: cmatrix.c:252:10: error: lvalue required as left operand of assignment COLS = win.ws_col; ^ cmatrix.c:253:11: error: lvalue required as left operand of assignment LINES = win.ws_row; ^ cmatrix.c:256:15: error: lvalue required as left operand of assignment LINES = 10; ^ cmatrix.c:259:14: error: lvalue required as left operand of assignment COLS = 10; ^ make[1]: [Makefile:425: cmatrix.o] Error 1 make[1]: Leaving directory '/home/rk/cmatrix' make: [Makefile:315: all] Error 2

rubenkr commented 6 years ago

@thorstenkampe @thunderactual if you delete lines 252–260 in cmatrix.c before ./configure, you can compile without problems on cygwin.

Downside: if you resize screen, you have to restart cmartix.

FliegendeWurst commented 6 years ago

This also happens on Linux.

abishekvashok commented 6 years ago

@FliegendeWurst really? If so can you state your software stack? I meant, the os, and other details that couldd help to investigate such a case?

FliegendeWurst commented 6 years ago

I'm using Opensuse Tumbleweed (update 20180925) and
gcc version 8.2.1 20180831 [gcc-8-branch revision 264010].

sallyx commented 5 years ago

The same problem on OpenSuSE 15 gcc (SUSE Linux) 7.3.1 20180323 [gcc-7-branch revision 258812]

cpp on cmatrix.c changes COLS to _nc_COLS() . You shoud not assign to COLS and ROWS.

fd00 commented 3 years ago

I made a temporary patch.

diff --git a/cmatrix.c b/cmatrix.c
index 73e069f..c1d846e 100644
--- a/cmatrix.c
+++ b/cmatrix.c
@@ -239,6 +239,7 @@ void sighandler(int s) {
 #endif

 void resize_screen(void) {
+    int lines, cols;
 #ifdef _WIN32
     BOOL result;
     HANDLE hStdHandle;
@@ -261,8 +262,8 @@ void resize_screen(void) {
     result = GetConsoleScreenBufferInfo(hStdHandle, &csbiInfo);
     if(!result)
         return;
-    LINES = csbiInfo.dwSize.Y;
-    COLS = csbiInfo.dwSize.X;
+    lines = csbiInfo.dwSize.Y;
+    cols = csbiInfo.dwSize.X;
 #else
     }
     fd = open(tty, O_RDWR);
@@ -274,21 +275,21 @@ void resize_screen(void) {
         return;
     }

-    COLS = win.ws_col;
-    LINES = win.ws_row;
+    cols = win.ws_col;
+    lines = win.ws_row;
 #endif

-    if(LINES <10){
-        LINES = 10;
+    if(lines <10){
+        lines = 10;
     }
-    if(COLS <10){
-        COLS = 10;
+    if(cols <10){
+        cols = 10;
     }

 #ifdef HAVE_RESIZETERM
-    resizeterm(LINES, COLS);
+    resizeterm(lines, cols);
 #ifdef HAVE_WRESIZE
-    if (wresize(stdscr, LINES, COLS) == ERR) {
+    if (wresize(stdscr, lines, cols) == ERR) {
         c_die("Cannot resize window!");
     }
 #endif /* HAVE_WRESIZE */
diff --git a/configure.ac b/configure.ac
index 1078f14..8499cce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ AM_INIT_AUTOMAKE

 AC_CANONICAL_HOST
 case $host in
-  *mingw*)
+  *mingw*|*cygwin*)
     ;;
   *)
     native_windows=no
abishekvashok commented 3 years ago

For guys running openSUSI, can you please try compiling by using $(ncursesw6-config --libs) or -L/usr/lib64/ncurses6 -lncursesw -ltinfo instead of -lncurses?

Reference: https://bugzilla.opensuse.org/show_bug.cgi?id=918553 https://forums.opensuse.org/showthread.php/522834-compilation-issue-with-cdk-library-and-LEAP-42-1

CC: @sallyx @FliegendeWurst

I kinda have a patch for Cygwin but before that can you make sure you have curses installed and is accessible by Cygwin? @fd00 @thorstenkampe @thunderactual as LINES and COLS are defined in curses.h

abishekvashok commented 3 years ago

I made a temporary patch.

Hey, it might work but clearly, we have to give up resizing here which is not acceptable :P

rashil2000 commented 3 years ago

Hi @abishekvashok! I tried compiling cmatrix today on MSYS2. It does complain about curses.h even after installing ncurses-devel package so doing this helps:

diff --git a/cmatrix.c b/cmatrix.c
index d1f6b98..26d0648 100644
--- a/cmatrix.c
+++ b/cmatrix.c
@@ -48,7 +48,7 @@
 #ifdef HAVE_NCURSES_H
 #include <ncurses.h>
 #else
-#include <curses.h>
+#include <ncurses/curses.h>
 #endif

 #ifdef HAVE_SYS_IOCTL_H

(This should ideally be wrapped under an ifdef for MSYS/Cygwin).

The project compiles, but while running cmatrix.exe, I get this Error opening terminal: xterm-256color

No terminal seems to work - mintty, Windows Terminal, Console Host etc.

abishekvashok commented 3 years ago

@rashil2000 thanks for trying out! This seems like a terminfo issue, can you try installing ncurses-term and then retrying?

rashil2000 commented 3 years ago

Hi @abishekvashok! ncurses-term seems to be an Debian specific package (file list here). The equivalent on MSys2 is ncurses (file list here) and mingw-w64-x86_64-ncurses (file list here), and I already have those two installed.

You can go through the file lists to see that all the files are there.

rashil2000 commented 3 years ago

@abishekvashok

My terminal emulator was setting the TERM variable to xterm-256color. Unsetting that fixes the issue - cmatrix works now!

abishekvashok commented 3 years ago

Hmm interesting. Thanks for staying with this. I will take a dig at this later this day/tomorrow.

rudolf81 commented 1 year ago

Hi @abishekvashok , any chance you can explain where to make this change? I've tried in a couple of places in the Makefile, and CMakeCache, etc (tried both cmake and ./configure routes) Thanks

For guys running openSUSI, can you please try compiling by using $(ncursesw6-config --libs) or -L/usr/lib64/ncurses6 -lncursesw -ltinfo instead of -lncurses?