Linker error when using C-Turtle library in C++

  archlinux, c++, g++, linker, turtle-graphics

So, I’ve decided to try to use the C-turtle library to make a pacman game. However, to test if the library works, I made a small program:

// All the custom headers
#include "../Headers/C-Turtle/CTurtle.hpp"

//Namespaces
namespace ct = cturtle;

// Main function
int main() {
    ct::TurtleScreen scr;
    ct::Turtle turtle(scr);
    turtle.forward(50);
    return 0;
}

However, upon trying to make it, I get this gargantuan error:

[[email protected] PacmanGame]$ make
g++ Sources/main.cpp -o Bin/Pacgame
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::cimg::Mutex_info::trylock(unsigned int)':
main.cpp:(.text._ZN12cimg_library4cimg10Mutex_info7trylockEj[_ZN12cimg_library4cimg10Mutex_info7trylockEj]+0x2b): undefined reference to `pthread_mutex_trylock'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::screen_width()':
main.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x2c): undefined reference to `XOpenDisplay'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x9e): undefined reference to `XCloseDisplay'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::screen_height()':
main.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x2c): undefined reference to `XOpenDisplay'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x9e): undefined reference to `XCloseDisplay'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::_handle_events(_XEvent const*)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x1d4): undefined reference to `XUnmapWindow'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x236): undefined reference to `XCheckWindowEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x326): undefined reference to `XResizeWindow'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x401): undefined reference to `XCheckWindowEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x45a): undefined reference to `XGetWindowAttributes'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x479): undefined reference to `XSync'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x4a2): undefined reference to `XSetInputFocus'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x5e7): undefined reference to `XCheckWindowEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x77a): undefined reference to `XCheckWindowEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x7be): undefined reference to `XLookupString'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x7f8): undefined reference to `XQueryKeymap'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x89e): undefined reference to `XLookupString'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x8ee): undefined reference to `XCheckWindowEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x9d6): undefined reference to `XCheckWindowEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0xa50): undefined reference to `XCheckWindowEvent'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::_events_thread(void*)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x84): undefined reference to `XCheckTypedEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0xb8): undefined reference to `XCheckMaskEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x19d): undefined reference to `pthread_testcancel'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::_set_colormap(unsigned long&, unsigned int)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay13_set_colormapERmj[_ZN12cimg_library11CImgDisplay13_set_colormapERmj]+0x2a6): undefined reference to `XStoreColors'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::_map_window()':
main.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x5b): undefined reference to `XMapRaised'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x87): undefined reference to `XWindowEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0xe3): undefined reference to `XGetWindowAttributes'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x102): undefined reference to `XSync'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::_paint(bool)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0x127): undefined reference to `XSendEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0x1b5): undefined reference to `XPutImage'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::_init_fullscreen()':
main.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x119): undefined reference to `XCreateWindow'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x20d): undefined reference to `XCreateImage'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x23d): undefined reference to `XSelectInput'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x25d): undefined reference to `XMapRaised'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x289): undefined reference to `XWindowEvent'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x30e): undefined reference to `XPutImage'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x339): undefined reference to `XGetWindowAttributes'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x358): undefined reference to `XSync'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::_desinit_fullscreen()':
main.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x35): undefined reference to `XUngrabKeyboard'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x5f): undefined reference to `XDestroyWindow'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x135): undefined reference to `XOpenDisplay'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x392): undefined reference to `XVisualIDFromVisual'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x3be): undefined reference to `XGetVisualInfo'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x41c): undefined reference to `XFree'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x463): undefined reference to `pthread_create'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x64c): undefined reference to `XCreateWindow'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x6d1): undefined reference to `XCreateSimpleWindow'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x70b): undefined reference to `XSelectInput'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x752): undefined reference to `XStoreName'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x7bb): undefined reference to `XCreateColormap'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x81f): undefined reference to `XSetWindowColormap'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x824): undefined reference to `XAllocClassHint'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x878): undefined reference to `XSetClassHint'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x887): undefined reference to `XFree'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x9a6): undefined reference to `XCreateImage'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x9d6): undefined reference to `XInternAtom'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0xa02): undefined reference to `XInternAtom'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0xa43): undefined reference to `XSetWMProtocols'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0xa88): undefined reference to `XGrabKeyboard'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::assign()':
main.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x124): undefined reference to `XDestroyWindow'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x19c): undefined reference to `XFreeColormap'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x1bc): undefined reference to `XSync'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::resize(int, int, bool)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x28f): undefined reference to `XResizeWindow'
/usr/bin/ld: main.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x2b6): undefined reference to `XGetWindowAttributes'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::close()':
main.cpp:(.text._ZN12cimg_library11CImgDisplay5closeEv[_ZN12cimg_library11CImgDisplay5closeEv]+0x8b): undefined reference to `XUnmapWindow'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `cimg_library::CImgDisplay::move(int, int)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay4moveEii[_ZN12cimg_library11CImgDisplay4moveEii]+0x84): undefined reference to `XMoveWindow'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `void cimg_library::CImgDisplay::_resize<unsigned char>(unsigned char, unsigned int, unsigned int, bool)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeIhEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeIhEEvT_jjb]+0x12d): undefined reference to `XCreateImage'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `void cimg_library::CImgDisplay::_resize<unsigned short>(unsigned short, unsigned int, unsigned int, bool)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeItEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeItEEvT_jjb]+0x135): undefined reference to `XCreateImage'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `void cimg_library::CImgDisplay::_resize<unsigned int>(unsigned int, unsigned int, unsigned int, bool)':
main.cpp:(.text._ZN12cimg_library11CImgDisplay7_resizeIjEEvT_jjb[_ZN12cimg_library11CImgDisplay7_resizeIjEEvT_jjb]+0x135): undefined reference to `XCreateImage'
/usr/bin/ld: /tmp/ccXl1Nkp.o: in function `std::thread::thread<cturtle::InteractiveTurtleScreen::initEventThread()::{lambda()#1}, , void>(cturtle::InteractiveTurtleScreen::initEventThread()::{lambda()#1}&&)':
main.cpp:(.text._ZNSt6threadC2IZN7cturtle23InteractiveTurtleScreen15initEventThreadEvEUlvE_JEvEEOT_DpOT0_[_ZNSt6threadC5IZN7cturtle23InteractiveTurtleScreen15initEventThreadEvEUlvE_JEvEEOT_DpOT0_]+0x2f): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make: *** [makefile:5: startmake] Error 1

If someone can understand this, what happened here?‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌

Source: Windows Questions C++

LEAVE A COMMENT