Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling on Cygwin #40

Open
thorstenkampe opened this issue Feb 11, 2018 · 19 comments · May be fixed by #116
Open

Error compiling on Cygwin #40

thorstenkampe opened this issue Feb 11, 2018 · 19 comments · May be fixed by #116

Comments

@thorstenkampe
Copy link

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
Copy link
Owner

GCC is version 6.4.0. Do you need more information?

Nope. Thanks for testing. :)

@abishekvashok
Copy link
Owner

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
Copy link

Bump. I am also getting the same error!

@abishekvashok
Copy link
Owner

@thunderactual mind helping :) ?

@rubenkr
Copy link

rubenkr commented May 14, 2018

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
Copy link

rubenkr commented May 14, 2018

@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.

acrisci pushed a commit to acrisci/cmatrix that referenced this issue Jun 13, 2018
On some systems, these are macros that expand to function getters which cannot be assigned to.

fixes abishekvashok#40
@FliegendeWurst
Copy link

This also happens on Linux.

@abishekvashok
Copy link
Owner

@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
Copy link

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

@sallyx
Copy link

sallyx commented Feb 16, 2019

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
Copy link

fd00 commented Nov 15, 2020

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

@berton7 berton7 linked a pull request Nov 18, 2020 that will close this issue
@abishekvashok
Copy link
Owner

abishekvashok commented Dec 15, 2020

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
Copy link
Owner

abishekvashok commented Dec 15, 2020

I made a temporary patch.

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

@rashil2000
Copy link
Contributor

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
Copy link
Owner

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

@rashil2000
Copy link
Contributor

rashil2000 commented Jan 26, 2021

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
Copy link
Contributor

@abishekvashok

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

@abishekvashok
Copy link
Owner

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

@rudolf81
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants