cimg library - linking error [closed]

 ̄綄美尐妖づ 提交于 2019-12-23 15:36:02

问题


I try to use the cimg library. I have included the CImg.h-header file. But when I try to compile it, I get a linking error.

/tmp/cc2tvYsW.o: In function `cimg_library::cimg::Mutex_info::trylock(unsigned int)':
tafelbilder.cpp:(.text._ZN12cimg_library4cimg10Mutex_info7trylockEj[_ZN12cimg_library4cimg10Mutex_info7trylockEj]+0x2b): undefined reference to `pthread_mutex_trylock'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::screen_width()':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x2c): undefined reference to `XOpenDisplay'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay12screen_widthEv[_ZN12cimg_library11CImgDisplay12screen_widthEv]+0x98): undefined reference to `XCloseDisplay'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::screen_height()':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x2c): undefined reference to `XOpenDisplay'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay13screen_heightEv[_ZN12cimg_library11CImgDisplay13screen_heightEv]+0x98): undefined reference to `XCloseDisplay'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::_handle_events(_XEvent const*)':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0xc7): undefined reference to `XUnmapWindow'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x12a): undefined reference to `XCheckWindowEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x218): undefined reference to `XResizeWindow'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x2f5): undefined reference to `XCheckWindowEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x348): undefined reference to `XGetWindowAttributes'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x35e): undefined reference to `XSync'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x390): undefined reference to `XSetInputFocus'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x4ce): undefined reference to `XCheckWindowEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x64b): undefined reference to `XCheckWindowEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x68f): undefined reference to `XLookupString'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x6cc): undefined reference to `XQueryKeymap'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x775): undefined reference to `XLookupString'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x7c6): undefined reference to `XCheckWindowEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x8a9): undefined reference to `XCheckWindowEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent[_ZN12cimg_library11CImgDisplay14_handle_eventsEPK7_XEvent]+0x922): undefined reference to `XCheckWindowEvent'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::_events_thread(void*)':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x84): undefined reference to `XCheckTypedEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0xb8): undefined reference to `XCheckMaskEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay14_events_threadEPv[_ZN12cimg_library11CImgDisplay14_events_threadEPv]+0x19d): undefined reference to `pthread_testcancel'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::_set_colormap(unsigned long&, unsigned int)':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay13_set_colormapERmj[_ZN12cimg_library11CImgDisplay13_set_colormapERmj]+0x29d): undefined reference to `XStoreColors'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::_map_window()':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x5b): undefined reference to `XMapRaised'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x87): undefined reference to `XWindowEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0xeb): undefined reference to `XGetWindowAttributes'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay11_map_windowEv[_ZN12cimg_library11CImgDisplay11_map_windowEv]+0x10a): undefined reference to `XSync'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::_paint(bool)':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0x124): undefined reference to `XSendEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay6_paintEb[_ZN12cimg_library11CImgDisplay6_paintEb]+0x1b2): undefined reference to `XPutImage'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::_init_fullscreen()':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x117): undefined reference to `XCreateWindow'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x20e): undefined reference to `XCreateImage'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x23e): undefined reference to `XSelectInput'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x25e): undefined reference to `XMapRaised'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x28a): undefined reference to `XWindowEvent'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x30d): undefined reference to `XPutImage'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x338): undefined reference to `XGetWindowAttributes'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay16_init_fullscreenEv[_ZN12cimg_library11CImgDisplay16_init_fullscreenEv]+0x34e): undefined reference to `XSync'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::_desinit_fullscreen()':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x37): undefined reference to `XUngrabKeyboard'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv[_ZN12cimg_library11CImgDisplay19_desinit_fullscreenEv]+0x61): undefined reference to `XDestroyWindow'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool)':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x124): undefined reference to `XOpenDisplay'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x375): undefined reference to `XVisualIDFromVisual'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x3a1): undefined reference to `XGetVisualInfo'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x402): undefined reference to `XFree'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x447): undefined reference to `pthread_create'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x634): undefined reference to `XCreateWindow'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x6bc): undefined reference to `XCreateSimpleWindow'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x6f9): undefined reference to `XSelectInput'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x73e): undefined reference to `XStoreName'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x7a7): undefined reference to `XCreateColormap'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x80e): undefined reference to `XSetWindowColormap'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x813): undefined reference to `XAllocClassHint'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x861): undefined reference to `XSetClassHint'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x870): undefined reference to `XFree'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x98f): undefined reference to `XCreateImage'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x9c0): undefined reference to `XInternAtom'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0x9ed): undefined reference to `XInternAtom'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0xa31): undefined reference to `XSetWMProtocols'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb[_ZN12cimg_library11CImgDisplay7_assignEjjPKcjbb]+0xa76): undefined reference to `XGrabKeyboard'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::assign()':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x124): undefined reference to `XDestroyWindow'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x19c): undefined reference to `XFreeColormap'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay6assignEv[_ZN12cimg_library11CImgDisplay6assignEv]+0x1bc): undefined reference to `XSync'
/tmp/cc2tvYsW.o: In function `cimg_library::CImgDisplay::resize(int, int, bool)':
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x272): undefined reference to `XResizeWindow'
tafelbilder.cpp:(.text._ZN12cimg_library11CImgDisplay6resizeEiib[_ZN12cimg_library11CImgDisplay6resizeEiib]+0x299): undefined reference to `XGetWindowAttributes'
/tmp/cc2tvYsW.o: In function `cimg_l

回答1:


It works adding these compiler options

-L/usr/X11R6/lib -lm -lpthread -lX11



回答2:


You must also linking the library. Check your compiler instructions in order to know how do it.



来源:https://stackoverflow.com/questions/33327727/cimg-library-linking-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!