我在编译程序时遇到了一个令人困惑的问题。尽管/usr/include中有stdio.h文件,并且使用gcc命令编译没有错误,但在执行make命令时仍然遇到以下错误:
fatal error: stdio.h: No such file or directory
我已经执行了
sudo apt-get install libc6-dev
所以我很困惑为什么这个错误仍然存在。任何见解或建议将不胜感激。谢谢!
节目:
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main() {
Display *display;
Window root_window;
XEvent event;
// Open display connection
display = XOpenDisplay(NULL);
if (display == NULL) {
fprintf(stderr, "Unable to open display connection\n");
return 1;
}
// Get the root window
root_window = XRootWindow(display, DefaultScreen(display));
// Listen for mouse button events
XGrabButton(display, AnyButton, AnyModifier, root_window, True,
ButtonPressMask | ButtonReleaseMask, GrabModeSync, GrabModeAsync,
None, None);
printf("Intercepting mouse events...\n");
// Enter event loop
while (1) {
XNextEvent(display, &event);
if (event.type == ButtonPress) {
printf("Mouse button press event intercepted\n");
// Add your handling logic here
} else if (event.type == ButtonRelease) {
printf("Mouse button release event intercepted\n");
// Add your handling logic here
}
}
// Close display connection
XCloseDisplay(display);
return 0;
}
生成文件:
obj-m += program2.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules EXTRA_LDFLAGS="-L/usr/lib -lX11"
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
我希望运行“make”命令时不会遇到任何错误。
任何见解或建议将不胜感激
您有一个用于构建 Linux 内核模块的 Makefile。在 Linux 内核中没有 stdio 或 X,也没有 /usr/include。
我建议删除 Makefile 文件。