使用Dlib编程出现X11相关错误

版权声明:博客文章都是作者辛苦整理的,转载请注明出处,谢谢! https://blog.csdn.net/Quincuntial/article/details/53766638

文章作者:Tyan 博客:noahsnail.com | CSDN | 简书

在使用dlib库编写GUI程序时,链接时出现下面的错误,解决方案为:1. 命令行链接时添加-L/opt/X11/lib -lX11即可;2. IDE下编写C++程序,需要在Library search path(-L)中添加/opt/X11/lib,在Libraries(-l)中添加X11,重新编译链接即可。

Undefined symbols for architecture x86_64:
  "_XAllocColor", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XAllocSizeHints", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_size(int, int) in libdlib.a(gui_core_kernel_2.o)
  "_XChangeProperty", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XCheckIfEvent", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XClearArea", referenced from:
      dlib::base_window::invalidate_rectangle(dlib::rectangle const&) in libdlib.a(gui_core_kernel_2.o)
  "_XCloseDisplay", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libdlib.a(gui_core_kernel_2.o)
      nativefont::font_renderer::font_renderer::vals_internal::~vals_internal() in libdlib.a(fonts.o)
  "_XCloseIM", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libdlib.a(gui_core_kernel_2.o)
  "_XConvertSelection", referenced from:
      dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libdlib.a(gui_core_kernel_2.o)
  "_XCreateFontSet", referenced from:
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XCreateGC", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XCreateIC", referenced from:
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
  "_XCreatePixmap", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XCreateWindow", referenced from:
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
      dlib::gui_core_kernel_2_globals::event_handler_thread::thread() in libdlib.a(gui_core_kernel_2.o)
  "_XDefaultDepth", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XDestroyIC", referenced from:
      dlib::base_window::~base_window() in libdlib.a(gui_core_kernel_2.o)
  "_XDestroyWindow", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::close_window() in libdlib.a(gui_core_kernel_2.o)
  "_XExtentsOfFontSet", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XFillRectangle", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XFilterEvent", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XFlush", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_title(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::show() in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::hide() in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_size(int, int) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_pos(long, long) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::invalidate_rectangle(dlib::rectangle const&) in libdlib.a(gui_core_kernel_2.o)
      ...
  "_XFree", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_title(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_size(int, int) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_im_pos(long, long) in libdlib.a(gui_core_kernel_2.o)
  "_XFreeFontSet", referenced from:
      dlib::base_window::~base_window() in libdlib.a(gui_core_kernel_2.o)
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
      nativefont::font_renderer::font_renderer::vals_internal::~vals_internal() in libdlib.a(fonts.o)
  "_XFreeGC", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
      nativefont::font_renderer::font_renderer::vals_internal::~vals_internal() in libdlib.a(fonts.o)
  "_XFreeModifiermap", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::init_keyboard_mod_masks() in libdlib.a(gui_core_kernel_2.o)
  "_XFreePixmap", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
      nativefont::font_renderer::font_renderer::vals_internal::~vals_internal() in libdlib.a(fonts.o)
  "_XFreeStringList", referenced from:
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XGetICValues", referenced from:
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
  "_XGetImage", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XGetModifierMapping", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::init_keyboard_mod_masks() in libdlib.a(gui_core_kernel_2.o)
  "_XGetSelectionOwner", referenced from:
      dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libdlib.a(gui_core_kernel_2.o)
  "_XGetWindowProperty", referenced from:
      dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libdlib.a(gui_core_kernel_2.o)
  "_XInitImage", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XInitThreads", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::thread() in libdlib.a(gui_core_kernel_2.o)
  "_XInternAtom", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libdlib.a(gui_core_kernel_2.o)
      dlib::gui_core_kernel_2_globals::event_handler_thread::thread() in libdlib.a(gui_core_kernel_2.o)
  "_XLookupString", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XMapRaised", referenced from:
      dlib::base_window::show() in libdlib.a(gui_core_kernel_2.o)
  "_XMoveWindow", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_pos(long, long) in libdlib.a(gui_core_kernel_2.o)
  "_XNextEvent", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XOpenDisplay", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::thread() in libdlib.a(gui_core_kernel_2.o)
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XPeekIfEvent", referenced from:
      dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libdlib.a(gui_core_kernel_2.o)
  "_XPending", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XPutBackEvent", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libdlib.a(gui_core_kernel_2.o)
  "_XPutImage", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XQueryColor", referenced from:
      nativefont::font_renderer::font_renderer::vals_internal::color2rgb(unsigned long, _XDisplay*, unsigned long&) in libdlib.a(fonts.o)
  "_XResizeWindow", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_size(int, int) in libdlib.a(gui_core_kernel_2.o)
  "_XScreenNumberOfScreen", referenced from:
      dlib::base_window::get_display_size(unsigned long&, unsigned long&) const in libdlib.a(gui_core_kernel_2.o)
  "_XSelectInput", referenced from:
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
  "_XSendEvent", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libdlib.a(gui_core_kernel_2.o)
  "_XSetBackground", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XSetForeground", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XSetICValues", referenced from:
      dlib::base_window::set_im_pos(long, long) in libdlib.a(gui_core_kernel_2.o)
  "_XSetNormalHints", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_size(int, int) in libdlib.a(gui_core_kernel_2.o)
  "_XSetSelectionOwner", referenced from:
      dlib::put_on_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) in libdlib.a(gui_core_kernel_2.o)
  "_XSetWMName", referenced from:
      dlib::base_window::set_title(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) in libdlib.a(gui_core_kernel_2.o)
  "_XSetWMProtocols", referenced from:
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
  "_XTranslateCoordinates", referenced from:
      dlib::base_window::get_pos(long&, long&) in libdlib.a(gui_core_kernel_2.o)
  "_XUnmapWindow", referenced from:
      dlib::base_window::hide() in libdlib.a(gui_core_kernel_2.o)
  "_XVaCreateNestedList", referenced from:
      dlib::base_window::base_window(bool, bool) in libdlib.a(gui_core_kernel_2.o)
      dlib::base_window::set_im_pos(long, long) in libdlib.a(gui_core_kernel_2.o)
  "_XkbKeycodeToKeysym", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::init_keyboard_mod_masks() in libdlib.a(gui_core_kernel_2.o)
  "_XwcDrawString", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XwcFreeStringList", referenced from:
      dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libdlib.a(gui_core_kernel_2.o)
  "_XwcLookupString", referenced from:
      dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libdlib.a(gui_core_kernel_2.o)
  "_XwcTextExtents", referenced from:
      void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libdlib.a(fonts.o)
  "_XwcTextListToTextProperty", referenced from:
      dlib::base_window::set_title(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) in libdlib.a(gui_core_kernel_2.o)
  "_XwcTextPropertyToTextList", referenced from:
      dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libdlib.a(gui_core_kernel_2.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [3dCloud] Error 1

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券