LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2006, 01:03 PM   #1
jrbrearley
LQ Newbie
 
Registered: May 2006
Posts: 7

Rep: Reputation: 0
gcc compile error with X11 library routines


Can anyone tell me what this gcc compiler error is about?

gcc getfocuswindow.c
/tmp/ccRxQAIg.o: In function `main':
getfocuswindow.c.text+0x26): undefined reference to `XOpenDisplay'
getfocuswindow.c.text+0x64): undefined reference to `XGetInputFocus'
collect2: ld returned 1 exit status

The h files are located in /usr/include/X11. The libX11.so is in /usr/lib. Am I missing some environment variable or something?

The code being compiled is shown below:

// Written by John Brearley, 2006
// Returns the name of the currently focused Unix X11 window.

#include <stdio.h>
//#include <X11/Core.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>

main()
{
char *display_name = NULL;
Display *display; //defined in Xlib.h
int i=1;

if (display=XOpenDisplay(display_name)) {
printf("OK\n");
} else {
printf("Failed\n");
}

i=XGetInputFocus(display,None,RevertToNone);
printf("i=%d\n",i);
}
 
Old 07-26-2006, 01:33 PM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
gcc something.c -o something -lX11
You forgot -lX11
 
Old 07-26-2006, 01:50 PM   #3
jrbrearley
LQ Newbie
 
Registered: May 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks, that seems to do the trick.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error:25066067:DSO support routines :DLFCN_LOAD:could not load the shared library berserker-ky Linux - Wireless Networking 1 02-20-2006 10:20 PM
compile error srgp library in C csst0136 Programming 13 10-25-2005 09:36 PM
Can't active Library routines CRC32 in fedora 4 smashhead Linux - Wireless Networking 0 08-07-2005 12:20 AM
compile GCC 4.0 error! ayiiq180 Linux - Software 3 04-22-2005 04:04 PM
NSS will not compile due to nspr4 library error juliensteel Linux - General 0 01-21-2005 08:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration