stefanhaustein / TerminalImageViewer

Small C++ program to display images in a (modern) terminal using RGB ANSI codes and unicode block graphics characters
Other
1.56k stars 111 forks source link

make doesn't compile #132

Closed kurokirasama closed 9 months ago

kurokirasama commented 9 months ago

Describe the Bug

Hey, I've used this tool for quiet a while now and I have it up and running in 2 ubuntu 20.04 laptops. Now I'm trying to install it in a new machine, with ubuntu 20.04 , but I got this error when running make

g++ -O2 -fpermissive -std=c++20 -Wall -fexceptions   -c -o tiv.o tiv.cpp           
g++: error: unrecognized command line option ‘-std=c++20’; did you mean            
‘-std=c++2a’?                                                                      

make: *** [<builtin>: tiv.o] Error 1 

g++ version:

g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0

Using the c++2a option as suggested, gives this:

g++ -O2 -fpermissive -std=c++2a -Wall -fexceptions   -c -o tiv.o tiv.cpp
tiv.cpp: In function ‘void emit_color(const int&, int, int, int)’:                                                                                      
tiv.cpp:428:28: error: invalid initialization of reference of type ‘const int (&)[]’ from expression of type ‘const int [6]’                            
  428 |     int ri = best_index(r, COLOR_STEPS, COLOR_STEP_COUNT);                                                                                      
      |                            ^~~~~~~~~~~                                                                                                          
tiv.cpp:402:39: note: in passing argument 2 of ‘int best_index(int, const int (&)[], int)’                                                              
  402 | int best_index(int value, const int (&STEPS)[], int count) {                                                                                    
      |                           ~~~~~~~~~~~~^~~~~~~~                                                                                                  
tiv.cpp:429:28: error: invalid initialization of reference of type ‘const int (&)[]’ from expression of type ‘const int [6]’                            
  429 |     int gi = best_index(g, COLOR_STEPS, COLOR_STEP_COUNT);                                                                                      
      |                            ^~~~~~~~~~~                                                                                                          
tiv.cpp:402:39: note: in passing argument 2 of ‘int best_index(int, const int (&)[], int)’                                                              
  402 | int best_index(int value, const int (&STEPS)[], int count) {                                                                                    
      |                           ~~~~~~~~~~~~^~~~~~~~                                                                                                  
tiv.cpp:430:28: error: invalid initialization of reference of type ‘const int (&)[]’ from expression of type ‘const int [6]’                            
  430 |     int bi = best_index(b, COLOR_STEPS, COLOR_STEP_COUNT);                                                                                      
      |                            ^~~~~~~~~~~                                                                                                          
tiv.cpp:402:39: note: in passing argument 2 of ‘int best_index(int, const int (&)[], int)’                                                              
  402 | int best_index(int value, const int (&STEPS)[], int count) {                                                                                    
      |                           ~~~~~~~~~~~~^~~~~~~~                                                                                                  
tiv.cpp:439:32: error: invalid initialization of reference of type ‘const int (&)[]’ from expression of type ‘const int [24]’                          
  439 |     int gri = best_index(gray, GRAYSCALE_STEPS, GRAYSCALE_STEP_COUNT);                                                                          
      |                                ^~~~~~~~~~~~~~~                                                                                                  
tiv.cpp:402:39: note: in passing argument 2 of ‘int best_index(int, const int (&)[], int)’                                                              
  402 | int best_index(int value, const int (&STEPS)[], int count) {                                                                                    
      |                           ~~~~~~~~~~~~^~~~~~~~                                                                                                  
make: *** [<builtin>: tiv.o] Error 1]

To Reproduce

clone the repo, cd to TerminalImageViewer/src and run make

Expected Behavio(u)r

it should compile

Screenshots

No response

Version/Commit Hash

just cloned

OS Specifics

Linux kira 5.15.0-89-generic #99~20.04.1-Ubuntu SMP Thu Nov 2 15:16:47 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

stefanhaustein commented 9 months ago

Can you try without the flag? Maybe it's no longer needed anyway...

Am Mi., 6. Dez. 2023 um 17:33 Uhr schrieb kurokirasama < @.***>:

Describe the Bug

Hey, I've used this tool for quiet a while now and I have it up and running in 2 ubuntu 20.04 laptops. Now I'm trying to install it in a new machine, with ubuntu 20.04 , but I got this error when running make

g++ -O2 -fpermissive -std=c++20 -Wall -fexceptions -c -o tiv.o tiv.cpp g++: error: unrecognized command line option ‘-std=c++20’; did you mean ‘-std=c++2a’?

make: *** [: tiv.o] Error 1

g++ version:

g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0

To Reproduce

clone the repo, cd to TerminalImageViewer/src and run make Expected Behavio(u)r

it should compile Screenshots

No response Version/Commit Hash

just cloned OS Specifics

Linux kira 5.15.0-89-generic #99 https://github.com/stefanhaustein/TerminalImageViewer/issues/99~20.04.1-Ubuntu SMP Thu Nov 2 15:16:47 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

— Reply to this email directly, view it on GitHub https://github.com/stefanhaustein/TerminalImageViewer/issues/132, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAVPT6AWNHBJBY6LF47Y2DYICM6TAVCNFSM6AAAAABAJVGBC2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZDQOJVGI4TEOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

aaronliu0130 commented 9 months ago

Problem seems to be with the signature of best_index. I tried to make it pass by reference for some reason and apparently I only tested compiling it with MSVC :p

aaronliu0130 commented 9 months ago

@kurokirasama Does it compile now?

kurokirasama commented 9 months ago

yes, it compiles just fine!! However, when using it now, I get this message:

Warning: failed to determine most reasonable size: unrecognized system, defaulting to 80x24

And the image is tiny. Screenshot from 2023-12-06 21-39-21

aaronliu0130 commented 9 months ago

It seems like I've used the wrong macro for detecting Unix systems. It really should actually work now, try to make it again. Sorry...

kurokirasama commented 9 months ago

now it works flawlessly!!! Thanks!