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

Fails to build and run in Gentoo #8

Open
acidrums4 opened this issue Jul 22, 2022 · 0 comments
Open

Fails to build and run in Gentoo #8

acidrums4 opened this issue Jul 22, 2022 · 0 comments

Comments

@acidrums4
Copy link

Greetings,

I've tried so long to successfully run this game but sadly, still can't.

In Gentoo (amd64, gcc-11.3.0, glibc-2.34-r13, ld 2.37, ncurses-6.3_p20220423) it fails to build:

mkdir -p bin build                                     
g++  build/main.o  build/shape.o  build/screen.o  build/game.o  build/functions.o -std=c++11 -MMD -MP  -O2 -lncursesw -o bin/tetris
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: build/main.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status                                                                                                                                    
make: *** [Makefile:30: main] Error 1

But learned that adding -ltinfo in Makefile's CXXFLAGS var lets it build:

mkdir -p bin build 
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/main.o src/main.cpp -c -o build/main.o
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/shape.o src/shape.cpp -c -o build/shape.o
src/shape.cpp: In member function 'void Shape::draw()':
src/shape.cpp:246:25: warning: format not a string literal and no format arguments [-Wformat-security]
246 |                 mvprintw(currentPos[0], currentPos[1], string("██").c_str());
|                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shape.cpp:249:25: warning: format not a string literal and no format arguments [-Wformat-security]
249 |                 mvprintw(currentPos[0], currentPos[1], string("").c_str());
|                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shape.cpp: In member function 'void Shape::groundDraw(int)':
src/shape.cpp:380:25: warning: format not a string literal and no format arguments [-Wformat-security]
380 |                 mvprintw(currentPos[0], currentPos[1], string("░░").c_str());
|                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shape.cpp:383:25: warning: format not a string literal and no format arguments [-Wformat-security]
383 |                 mvprintw(currentPos[0], currentPos[1], string("").c_str());
|                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/screen.o src/screen.cpp -c -o build/screen.o
src/screen.cpp: In member function 'void Screen::top()':
src/screen.cpp:30:11: warning: format not a string literal and no format arguments [-Wformat-security]
30 |     printw(readLine(screenstr, 0).c_str());
|     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/screen.cpp: In member function 'void Screen::draw()':
src/screen.cpp:64:27: warning: format not a string literal and no format arguments [-Wformat-security]
64 |                     printw(printChar.c_str());
|                     ~~~~~~^~~~~~~~~~~~~~~~~~~
src/screen.cpp:71:27: warning: format not a string literal and no format arguments [-Wformat-security]
71 |                     printw(string(" ").c_str());
|                     ~~~~~~^~~~~~~~~~~~~~~~~~~~~
src/screen.cpp:75:23: warning: format not a string literal and no format arguments [-Wformat-security]
75 |                 printw(window[i][j].c_str());
|                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
src/screen.cpp:78:15: warning: format not a string literal and no format arguments [-Wformat-security]
78 |         printw(string("\n").c_str());
|         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/game.o src/game.cpp -c -o build/game.o
src/game.cpp: In function 'void game(Shape, Screen, int, bool, std::string)':
src/game.cpp:166:13: warning: format not a string literal and no format arguments [-Wformat-security]
166 |     mvprintw(9,8,string("Game over!").c_str());
|     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/game.cpp:167:13: warning: format not a string literal and no format arguments [-Wformat-security]
167 |     mvprintw(10,5,string("Try again? (y/n)").c_str());
|     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/functions.o src/functions.cpp -c -o build/functions.o
g++  build/main.o  build/shape.o  build/screen.o  build/game.o  build/functions.o -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -o bin/tetris

But trying to run the output binary (bin/tetris) causes a segfault (Sorry, can't provide a coredump since I don't have debug symbols set up).

Is there something I'm doing wrong here? Not familiar with Make or debugging so am kind of lost here.

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

No branches or pull requests

1 participant