Closed zero2cx closed 7 years ago
Jamal, this Arch Linux forum thread includes some discussion of problems identified within the Makefile as it existed before this pull request. There, you'll see that the updated Makefile I submit here was freely contributed to the project with the sole condition that the author does not want to be consulted in perpetuity by end-users. Hence, given freely to you with no attribution necessary. Cheers!
Hello @zero2cx ,
Thanks for the update. However, I've pulled this request locally to test it, and I am receiving errors. I typed "make", "make install", and "sudo make install" and received the same error output (posted below) each time.
I'm not an expert on Makefiles, so take this with a grain of salt, but I suspect there may be a linking problem with the ncurses library. Many of the errors say something like avatar.cpp:(.text+0x36f): undefined reference to
move'
`where 'move' is a function from ncurses, and the "undefined reference" error normally indicates a linking issue
This will have to be fixed before I can merge the branch. Also, are you getting this error when you run the Makefile?
g++ -lncurses -lpthread src/avatar.o src/ghost1.o src/helperFns.o src/game.o src/globals.o -o pacvim
src/avatar.o: In function `avatar::moveTo(int, int)':
avatar.cpp:(.text+0x36f): undefined reference to `move'
avatar.cpp:(.text+0x39a): undefined reference to `stdscr'
avatar.cpp:(.text+0x44c): undefined reference to `refresh'
src/ghost1.o: In function `Ghost1::eval()':
ghost1.cpp:(.text+0x92): undefined reference to `stdscr'
src/ghost1.o: In function `Ghost1::eval(int, int)':
ghost1.cpp:(.text+0x168): undefined reference to `stdscr'
src/helperFns.o: In function `charAt(int, int)':
helperFns.cpp:(.text+0x33): undefined reference to `stdscr'
src/helperFns.o: In function `writeAt(int, int, unsigned long)':
helperFns.cpp:(.text+0xbd): undefined reference to `stdscr'
src/helperFns.o: In function `writeAt(int, int, unsigned long, int)':
helperFns.cpp:(.text+0x153): undefined reference to `stdscr'
src/helperFns.o: In function `printAtBottomChar(char)':
helperFns.cpp:(.text+0x304): undefined reference to `mvprintw'
src/helperFns.o: In function `printAtBottom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
helperFns.cpp:(.text+0x36a): undefined reference to `stdscr'
helperFns.cpp:(.text+0x3a6): undefined reference to `mvprintw'
helperFns.cpp:(.text+0x3c4): undefined reference to `move'
src/helperFns.o: In function `winGame()':
helperFns.cpp:(.text+0x3f8): undefined reference to `clear'
helperFns.cpp:(.text+0x4f4): undefined reference to `refresh'
src/helperFns.o: In function `loseGame()':
helperFns.cpp:(.text+0x5d2): undefined reference to `clear'
helperFns.cpp:(.text+0x661): undefined reference to `refresh'
src/helperFns.o: In function `isValid(int, int)':
helperFns.cpp:(.text+0x73e): undefined reference to `stdscr'
src/helperFns.o: In function `__static_initialization_and_destruction_0(int, int)':
helperFns.cpp:(.text+0xf02): undefined reference to `acs_map'
helperFns.cpp:(.text+0xf0f): undefined reference to `acs_map'
helperFns.cpp:(.text+0xf1c): undefined reference to `acs_map'
helperFns.cpp:(.text+0xf29): undefined reference to `acs_map'
helperFns.cpp:(.text+0xf36): undefined reference to `acs_map'
src/helperFns.o:helperFns.cpp:(.text+0xf43): more undefined references to `acs_map' follow
src/helperFns.o: In function `CUR_addch(unsigned long)':
helperFns.cpp:(.text._Z9CUR_addchm[_Z9CUR_addchm]+0xf): undefined reference to `stdscr'
helperFns.cpp:(.text._Z9CUR_addchm[_Z9CUR_addchm]+0x1e): undefined reference to `waddch'
src/helperFns.o: In function `CUR_attroff(unsigned long)':
helperFns.cpp:(.text._Z11CUR_attroffm[_Z11CUR_attroffm]+0xf): undefined reference to `stdscr'
helperFns.cpp:(.text._Z11CUR_attroffm[_Z11CUR_attroffm]+0x23): undefined reference to `wattr_off'
src/helperFns.o: In function `CUR_attron(unsigned long)':
helperFns.cpp:(.text._Z10CUR_attronm[_Z10CUR_attronm]+0xf): undefined reference to `stdscr'
helperFns.cpp:(.text._Z10CUR_attronm[_Z10CUR_attronm]+0x23): undefined reference to `wattr_on'
src/helperFns.o: In function `CUR_mvinch(int, int)':
helperFns.cpp:(.text._Z10CUR_mvinchii[_Z10CUR_mvinchii]+0x11): undefined reference to `stdscr'
helperFns.cpp:(.text._Z10CUR_mvinchii[_Z10CUR_mvinchii]+0x21): undefined reference to `wmove'
helperFns.cpp:(.text._Z10CUR_mvinchii[_Z10CUR_mvinchii]+0x2d): undefined reference to `stdscr'
helperFns.cpp:(.text._Z10CUR_mvinchii[_Z10CUR_mvinchii]+0x35): undefined reference to `winch'
src/game.o: In function `doKeystroke(avatar&)':
game.cpp:(.text+0x236): undefined reference to `endwin'
src/game.o: In function `onKeystroke(avatar&, char)':
game.cpp:(.text+0x9b8): undefined reference to `refresh'
game.cpp:(.text+0xa6d): undefined reference to `refresh'
src/game.o: In function `levelMessage()':
game.cpp:(.text+0xb84): undefined reference to `printw'
game.cpp:(.text+0xb89): undefined reference to `refresh'
game.cpp:(.text+0xb98): undefined reference to `clear'
game.cpp:(.text+0xba7): undefined reference to `move'
game.cpp:(.text+0xbac): undefined reference to `refresh'
src/game.o: In function `drawScreen(char const*)':
game.cpp:(.text+0xc48): undefined reference to `clear'
game.cpp:(.text+0x1871): undefined reference to `acs_map'
game.cpp:(.text+0x18a0): undefined reference to `acs_map'
game.cpp:(.text+0x18cf): undefined reference to `acs_map'
game.cpp:(.text+0x18fe): undefined reference to `acs_map'
game.cpp:(.text+0x192d): undefined reference to `acs_map'
src/game.o:game.cpp:(.text+0x1953): more undefined references to `acs_map' follow
src/game.o: In function `defineColors()':
game.cpp:(.text+0x1e70): undefined reference to `start_color'
game.cpp:(.text+0x1e84): undefined reference to `init_pair'
game.cpp:(.text+0x1e98): undefined reference to `init_pair'
game.cpp:(.text+0x1eac): undefined reference to `init_pair'
game.cpp:(.text+0x1ec0): undefined reference to `init_pair'
game.cpp:(.text+0x1ed4): undefined reference to `init_pair'
src/game.o:game.cpp:(.text+0x1ee8): more undefined references to `init_pair' follow
src/game.o: In function `playGame(long, avatar&)':
game.cpp:(.text+0x2004): undefined reference to `endwin'
game.cpp:(.text+0x2183): undefined reference to `move'
game.cpp:(.text+0x2188): undefined reference to `refresh'
game.cpp:(.text+0x21a1): undefined reference to `clear'
src/game.o: In function `init(char const*)':
game.cpp:(.text+0x22a0): undefined reference to `clear'
src/game.o: In function `checkParams(int, char**)':
game.cpp:(.text+0x26c6): undefined reference to `endwin'
game.cpp:(.text+0x277a): undefined reference to `endwin'
game.cpp:(.text+0x27b5): undefined reference to `endwin'
src/game.o: In function `main':
game.cpp:(.text+0x28c6): undefined reference to `initscr'
game.cpp:(.text+0x28d7): undefined reference to `noecho'
game.cpp:(.text+0x2afb): undefined reference to `endwin'
src/game.o: In function `CUR_getch()':
game.cpp:(.text._Z9CUR_getchv[_Z9CUR_getchv]+0x7): undefined reference to `stdscr'
game.cpp:(.text._Z9CUR_getchv[_Z9CUR_getchv]+0xf): undefined reference to `wgetch'
src/game.o: In function `std::thread::thread<void (Ghost1::*)(bool), Ghost1&, bool>(void (Ghost1::*&&)(bool), Ghost1&, bool&&)':
game.cpp:(.text._ZNSt6threadC2IM6Ghost1FvbEJRS1_bEEEOT_DpOT0_[_ZNSt6threadC5IM6Ghost1FvbEJRS1_bEEEOT_DpOT0_]+0xc9): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
Makefile:17: recipe for target 'pacvim' failed
make: *** [
g++ -lncurses -lpthread src/avatar.o src/ghost1.o src/helperFns.o src/game.o src/globals.o -o pacvim
src/avatar.o: In function `avatar::moveTo(int, int)':
avatar.cpp:(.text+0x36f): undefined reference to `move'
avatar.cpp:(.text+0x39a): undefined reference to `stdscr'
avatar.cpp:(.text+0x44c): undefined reference to `refresh'
src/ghost1.o: In function `Ghost1::eval()':
ghost1.cpp:(.text+0x92): undefined reference to `stdscr'
src/ghost1.o: In function `Ghost1::eval(int, int)':
ghost1.cpp:(.text+0x168): undefined reference to `stdscr'
src/helperFns.o: In function `charAt(int, int)':
helperFns.cpp:(.text+0x33): undefined reference to `stdscr'
src/helperFns.o: In function `writeAt(int, int, unsigned long)':
helperFns.cpp:(.text+0xbd): undefined reference to `stdscr'
src/helperFns.o: In function `writeAt(int, int, unsigned long, int)':
helperFns.cpp:(.text+0x153): undefined reference to `stdscr'
src/helperFns.o: In function `printAtBottomChar(char)':
helperFns.cpp:(.text+0x304): undefined reference to `mvprintw'
src/helperFns.o: In function `printAtBottom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
helperFns.cpp:(.text+0x36a): undefined reference to `stdscr'
helperFns.cpp:(.text+0x3a6): undefined reference to `mvprintw'
helperFns.cpp:(.text+0x3c4): undefined reference to `move'
src/helperFns.o: In function `winGame()':
helperFns.cpp:(.text+0x3f8): undefined reference to `clear'
helperFns.cpp:(.text+0x4f4): undefined reference to `refresh'
src/helperFns.o: In function `loseGame()':
helperFns.cpp:(.text+0x5d2): undefined reference to `clear'
helperFns.cpp:(.text+0x661): undefined reference to `refresh'
src/helperFns.o: In function `isValid(int, int)':
helperFns.cpp:(.text+0x73e): undefined reference to `stdscr'
src/helperFns.o: In function `__static_initialization_and_destruction_0(int, int)':
helperFns.cpp:(.text+0xf02): undefined reference to `acs_map'
helperFns.cpp:(.text+0xf0f): undefined reference to `acs_map'
helperFns.cpp:(.text+0xf1c): undefined reference to `acs_map'
helperFns.cpp:(.text+0xf29): undefined reference to `acs_map'
helperFns.cpp:(.text+0xf36): undefined reference to `acs_map'
src/helperFns.o:helperFns.cpp:(.text+0xf43): more undefined references to `acs_map' follow
src/helperFns.o: In function `CUR_addch(unsigned long)':
helperFns.cpp:(.text._Z9CUR_addchm[_Z9CUR_addchm]+0xf): undefined reference to `stdscr'
helperFns.cpp:(.text._Z9CUR_addchm[_Z9CUR_addchm]+0x1e): undefined reference to `waddch'
src/helperFns.o: In function `CUR_attroff(unsigned long)':
helperFns.cpp:(.text._Z11CUR_attroffm[_Z11CUR_attroffm]+0xf): undefined reference to `stdscr'
helperFns.cpp:(.text._Z11CUR_attroffm[_Z11CUR_attroffm]+0x23): undefined reference to `wattr_off'
src/helperFns.o: In function `CUR_attron(unsigned long)':
helperFns.cpp:(.text._Z10CUR_attronm[_Z10CUR_attronm]+0xf): undefined reference to `stdscr'
helperFns.cpp:(.text._Z10CUR_attronm[_Z10CUR_attronm]+0x23): undefined reference to `wattr_on'
src/helperFns.o: In function `CUR_mvinch(int, int)':
helperFns.cpp:(.text._Z10CUR_mvinchii[_Z10CUR_mvinchii]+0x11): undefined reference to `stdscr'
helperFns.cpp:(.text._Z10CUR_mvinchii[_Z10CUR_mvinchii]+0x21): undefined reference to `wmove'
helperFns.cpp:(.text._Z10CUR_mvinchii[_Z10CUR_mvinchii]+0x2d): undefined reference to `stdscr'
helperFns.cpp:(.text._Z10CUR_mvinchii[_Z10CUR_mvinchii]+0x35): undefined reference to `winch'
src/game.o: In function `doKeystroke(avatar&)':
game.cpp:(.text+0x236): undefined reference to `endwin'
src/game.o: In function `onKeystroke(avatar&, char)':
game.cpp:(.text+0x9b8): undefined reference to `refresh'
game.cpp:(.text+0xa6d): undefined reference to `refresh'
src/game.o: In function `levelMessage()':
game.cpp:(.text+0xb84): undefined reference to `printw'
game.cpp:(.text+0xb89): undefined reference to `refresh'
game.cpp:(.text+0xb98): undefined reference to `clear'
game.cpp:(.text+0xba7): undefined reference to `move'
game.cpp:(.text+0xbac): undefined reference to `refresh'
src/game.o: In function `drawScreen(char const*)':
game.cpp:(.text+0xc48): undefined reference to `clear'
game.cpp:(.text+0x1871): undefined reference to `acs_map'
game.cpp:(.text+0x18a0): undefined reference to `acs_map'
game.cpp:(.text+0x18cf): undefined reference to `acs_map'
game.cpp:(.text+0x18fe): undefined reference to `acs_map'
game.cpp:(.text+0x192d): undefined reference to `acs_map'
src/game.o:game.cpp:(.text+0x1953): more undefined references to `acs_map' follow
src/game.o: In function `defineColors()':
game.cpp:(.text+0x1e70): undefined reference to `start_color'
game.cpp:(.text+0x1e84): undefined reference to `init_pair'
game.cpp:(.text+0x1e98): undefined reference to `init_pair'
game.cpp:(.text+0x1eac): undefined reference to `init_pair'
game.cpp:(.text+0x1ec0): undefined reference to `init_pair'
game.cpp:(.text+0x1ed4): undefined reference to `init_pair'
src/game.o:game.cpp:(.text+0x1ee8): more undefined references to `init_pair' follow
src/game.o: In function `playGame(long, avatar&)':
game.cpp:(.text+0x2004): undefined reference to `endwin'
game.cpp:(.text+0x2183): undefined reference to `move'
game.cpp:(.text+0x2188): undefined reference to `refresh'
game.cpp:(.text+0x21a1): undefined reference to `clear'
src/game.o: In function `init(char const*)':
game.cpp:(.text+0x22a0): undefined reference to `clear'
src/game.o: In function `checkParams(int, char**)':
game.cpp:(.text+0x26c6): undefined reference to `endwin'
game.cpp:(.text+0x277a): undefined reference to `endwin'
game.cpp:(.text+0x27b5): undefined reference to `endwin'
src/game.o: In function `main':
game.cpp:(.text+0x28c6): undefined reference to `initscr'
game.cpp:(.text+0x28d7): undefined reference to `noecho'
game.cpp:(.text+0x2afb): undefined reference to `endwin'
src/game.o: In function `CUR_getch()':
game.cpp:(.text._Z9CUR_getchv[_Z9CUR_getchv]+0x7): undefined reference to `stdscr'
game.cpp:(.text._Z9CUR_getchv[_Z9CUR_getchv]+0xf): undefined reference to `wgetch'
src/game.o: In function `std::thread::thread<void (Ghost1::*)(bool), Ghost1&, bool>(void (Ghost1::*&&)(bool), Ghost1&, bool&&)':
game.cpp:(.text._ZNSt6threadC2IM6Ghost1FvbEJRS1_bEEEOT_DpOT0_[_ZNSt6threadC5IM6Ghost1FvbEJRS1_bEEEOT_DpOT0_]+0xc9): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
Makefile:17: recipe for target 'pacvim' failed
make: *** [
pacvim] Error 1
I think that I have found the cause of the build errors that you encounter. Note that my own Arch Linux in a Virtualbox system does not report any of the build errors that you are seeing.
Simply try this to start. Hand-apply the following single line edit/patch to your local system and see if it builds for you. If it works as I think that it should, then either 1) you need to review/edit my pull request Makefile so it includes the new patch OR 2) I need to learn how to push my changes from my own forked code up to your original github repo here. Since I do not yet know how to accomplish the second (2), maybe you can try the first (1)?
My interpretation of the evidence here is that my system's g++ has probably been built to automatically use the Makefile's defined variable called CXXFLAGS, while your g++ has not. See below for what I am hoping is the fix you'll need (line 17):
$(TARGET): $(OBJS)
- $(CXX) $(LDFLAGS) $(LDLIBS) $^ -o $@
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) $^ -o $@
install: $(TARGET)
install -Dm755 $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
@zero2cx
I tried your adjustment but still received the same error. However, I was actually able to fix it by moving the $(LDLIBS)
flag to the end of the line so that it looks like:
$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS)
(This answer from Stackoverflow provided some guidance for this change)
If you can make this change locally, confirm that it works on your machine, commit, and push the change up, I can accept this pull request.
Thanks
PacVim with the fix does build for me without any problem. The most recent changes to Makefile in my fork include:
make clean
target.Very nice. I've now changed the pull request to include the newest working Makefile. Merge whenever your testing is complete. Thank you.
I tested it with success and merged the change. Thanks for the help.
This commit increases Makefile overall coherency by simplifying the file's general flow while also eliminating some of the extraneous bits. One notable issue fixed here is that CXXFLAGS will now be used in place of CFLAGS. Second, any flags issued by the user on the command-line are now incorporated in the make/build process whereas before, these were being disregarded. Finally, there was a problem that arose when forcing the addition of "-Wall" to the build command so as to increase feedback verbosity. Doing this would, in some environments, prevent the build from linking a final executable file and the process would exit-with-error, while complaining of a missing library.
This update to Makefile was contributed by a coder (not myself) who stated in a forum discussion that they do not wish attribution for their work here. Thank you, kind coder.