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

Undefined symbols for architecture x86_64 #21

Closed
lukywong opened this issue Oct 11, 2015 · 7 comments
Closed

Undefined symbols for architecture x86_64 #21

lukywong opened this issue Oct 11, 2015 · 7 comments

Comments

@lukywong
Copy link

Hi, I tried to compile one of the examples on mac os x 10.11, but i got below error.
$ g++ -o main captcha.cpp
Undefined symbols for architecture x86_64:
"_XAllocClassHint", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XCheckMaskEvent", referenced from:
cimg_library::CImgDisplay::events_thread(void) in captcha-e2d6a3.o
"_XCheckTypedEvent", referenced from:
cimg_library::CImgDisplay::events_thread(void) in captcha-e2d6a3.o
"_XCheckWindowEvent", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XCloseDisplay", referenced from:
cimg_library::CImgDisplay::screen_width() in captcha-e2d6a3.o
cimg_library::CImgDisplay::screen_height() in captcha-e2d6a3.o
"_XCreateColormap", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XCreateImage", referenced from:
void cimg_library::CImgDisplay::_resize(unsigned char, unsigned int, unsigned int, bool) in captcha-e2d6a3.o
void cimg_library::CImgDisplay::_resize(unsigned short, unsigned int, unsigned int, bool) in captcha-e2d6a3.o
void cimg_library::CImgDisplay::_resize(unsigned int, unsigned int, unsigned int, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
"_XCreateSimpleWindow", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XCreateWindow", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
"_XDestroyWindow", referenced from:
cimg_library::CImgDisplay::assign() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_desinit_fullscreen() in captcha-e2d6a3.o
"_XFree", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XFreeColormap", referenced from:
cimg_library::CImgDisplay::assign() in captcha-e2d6a3.o
"_XGetVisualInfo", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XGetWindowAttributes", referenced from:
cimg_library::CImgDisplay::resize(int, int, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_map_window() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XGrabKeyboard", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XInternAtom", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XLookupString", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XMapRaised", referenced from:
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_map_window() in captcha-e2d6a3.o
"_XMoveWindow", referenced from:
cimg_library::CImgDisplay::move(int, int) in captcha-e2d6a3.o
"_XOpenDisplay", referenced from:
cimg_library::CImgDisplay::screen_width() in captcha-e2d6a3.o
cimg_library::CImgDisplay::screen_height() in captcha-e2d6a3.o
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XPutImage", referenced from:
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_paint(bool) in captcha-e2d6a3.o
"_XQueryKeymap", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XResizeWindow", referenced from:
cimg_library::CImgDisplay::resize(int, int, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XSelectInput", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
"_XSendEvent", referenced from:
cimg_library::CImgDisplay::_paint(bool) in captcha-e2d6a3.o
"_XSetClassHint", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XSetInputFocus", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XSetWMProtocols", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XSetWindowColormap", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XStoreColors", referenced from:
cimg_library::CImgDisplay::_set_colormap(unsigned long&, unsigned int) in captcha-e2d6a3.o
"_XStoreName", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XSync", referenced from:
cimg_library::CImgDisplay::assign() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_map_window() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XUngrabKeyboard", referenced from:
cimg_library::CImgDisplay::_desinit_fullscreen() in captcha-e2d6a3.o
"_XUnmapWindow", referenced from:
cimg_library::CImgDisplay::_handle_events(XEvent const) in captcha-e2d6a3.o
"_XVisualIDFromVisual", referenced from:
cimg_library::CImgDisplay::assign(unsigned int, unsigned int, char const, unsigned int, bool, bool) in captcha-e2d6a3.o
"_XWindowEvent", referenced from:
cimg_library::CImgDisplay::_init_fullscreen() in captcha-e2d6a3.o
cimg_library::CImgDisplay::_map_window() in captcha-e2d6a3.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@dtschump
Copy link
Collaborator

Looks like you forgot to link your code with the X11 library:

$ g++ -o foo foo.cpp -lX11 -lpthread

or, if you don't have X11 installed and if you don't want display capabilities of CImg:

$ g++ -o foo foo.cpp -Dcimg_display=0

@lukywong
Copy link
Author

Thank you, all ok after installing x11

@caiyzik
Copy link

caiyzik commented Jan 20, 2018

I tried doing this to no avail. I also used -L/opt/X11 and I still get the same errors

@devernay
Copy link

@trmontgomery did you install xquartz ? (google it)

@caiyzik
Copy link

caiyzik commented Jan 22, 2018

@devernay Yes I did.

@devernay
Copy link

devernay commented Jan 22, 2018

did you use this compile line:

clang++ -I .. -I /opt/X11/include captcha.cpp -L /opt/X11/lib -lX11 -o captcha

@caiyzik
Copy link

caiyzik commented Jan 22, 2018

@devernay Wow that worked! Any idea on why I can't compile with g++? (Edit: Apparently the gcc that comes with Mac is just clang...)

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

4 participants