linker - linking issue with x11 in C -


i'm trying build getpixelcolor function using x11:

#include <stdio.h> #include <x11/xlib.h> #include <x11/xutil.h>  void getpixelcolor (display *d, int x, int y, xcolor *color) {     ximage *image;     image = xgetimage (d, rootwindow (d, defaultscreen (d)), x, y, 1, 1, allplanes,               xypixmap);     color->pixel = xgetpixel (image, 0, 0);     xfree (image);     xquerycolor (d, defaultcolormap(d, defaultscreen (d)), color); }  int main(int argc, const char * argv[]) {    return 0; } 

however getting following error, seems it's during linking:

undefined symbols architecture x86_64:   "_xgetimage", referenced from:   _getpixelcolor in main.o   "_xfree", referenced from:   _getpixelcolor in main.o   "_xquerycolor", referenced from:   _getpixelcolor in main.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) 

any idea issue be? under impression x11 wasn't framework link library in project - long supply correct header, should fine... incorrect?

yes, need link xlib. works me:

09:25 tmp $ gcc test.cpp /usr/x11/lib/libx11.dylib  09:26 tmp $ ./a.out  09:26 tmp $ 

or l switch , library path:

09:26 tmp $ gcc test.cpp -l/usr/x11/lib -lx11 09:30 tmp $ otool -l a.out  a.out:     /usr/x11/lib/libx11.6.dylib (compatibility version 10.0.0, current version 10.0.0)     /usr/lib/libsystem.b.dylib (compatibility version 1.0.0, current version 159.1.0)  

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -