Reputation: 111
I am currently running the latest version of Code-blocks in Ubuntu 11.04. I have GTK+2, and 3 developer libraries fully installed (and working), and presumably have x11 installed. The header files are there.
However, a simple code will not compile using x11 coding.
#include "X11/Xlib.h"
int main() {
Display *display = XOpenDisplay(0);
Window root = DefaultRootWindow(display);
XWarpPointer(display, None, root, 0, 0, 0, 0, 100, 100);
XCloseDisplay(display);
return 0;
}
This give me the readout of:
obj/Release/main.o||In function `main':|
undefined reference to `XOpenDisplay'
undefined reference to `XWarpPointer'
undefined reference to `XCloseDisplay'
|=== Build finished: 3 errors, 0 warnings ===|
I've tried reading multiple webpages of 'linking' x11, I only find headerfiles, and not the file type asked by the linker within the compiler (That's the wrong term for that.. it's not a compiler.. it's something else.. I know. Apologies)
Upvotes: 4
Views: 4562
Reputation: 285
In CodeBlocks you can just set in the project options libraries to link against, setting -lX11 in the compiler settings will make every program you compile with codeblocks link against X11.
Upvotes: 0
Reputation: 542
Thanks! I just had the same problem. To spell it out:
Settings > Compiler and Debugger > Linker settings > Other linker options > "-lX11"
For the record 'codelite' got it right all by itself.
Upvotes: 2
Reputation: 4180
I don't know what Code Blocks is, but for a normal compile/link process, you need to specify -lX11
to link with libX11.so for the Xlib functions.
Upvotes: 5