我正在尝试使用 X11 构建一个 getPixelColor 函数:
#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;
}
但是我收到以下错误,似乎是在链接期间:
Undefined symbols for 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 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
知道问题可能是什么吗?我的印象是 X11 不是我在项目中作为库链接的框架 - 只要我提供正确的标题,那么我应该没问题......这是不正确的吗?