LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-23-2006, 02:37 AM   #1
nawin_g
LQ Newbie
 
Registered: Nov 2005
Posts: 19

Rep: Reputation: 0
X11 - GCC compiling options


hi,

i have a C program to compile with X11 library included

i tried compiling using these flags
____________________________________________________________
gcc -g -v -L/usr/X11R6/lib -lX11 -lXtst test.c
____________________________________________________________
and i am getting the following error

_____________________________________________________________
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.0.0 20050519 (Red Hat 4.0.0-8)
/usr/libexec/gcc/x86_64-redhat-linux/4.0.0/cc1 -quiet -v test.c -quiet -dumpbase test.c -mtune=k8 -auxbase test -g -version -o /tmp/ccyB1ded.s
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.0.0/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-redhat-linux/4.0.0/include
/usr/include
End of search list.
GNU C version 4.0.0 20050519 (Red Hat 4.0.0-8) (x86_64-redhat-linux)
compiled by GNU C version 4.0.0 20050519 (Red Hat 4.0.0-8).
GGC heuristics: --param ggc-min-expand=68 --param ggc-min-heapsize=71720
as -V -Qy -o /tmp/cc0EFTJs.o /tmp/ccyB1ded.s
GNU assembler version 2.15.94.0.2.2 (x86_64-redhat-linux) using BFD version 2.15.94.0.2.2 20041220
/usr/libexec/gcc/x86_64-redhat-linux/4.0.0/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-redhat-linux/4.0.0/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.0.0/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.0.0/crtbegin.o -L/usr/X11R6/lib -L/usr/lib/gcc/x86_64-redhat-linux/4.0.0 -L/usr/lib/gcc/x86_64-redhat-linux/4.0.0 -L/usr/lib/gcc/x86_64-redhat-linux/4.0.0/../../../../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.0.0/../../.. -L/lib/../lib64 -L/usr/lib/../lib64 -lX11 -lXtst /tmp/cc0EFTJs.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/4.0.0/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.0.0/../../../../lib64/crtn.o
/usr/bin/ld: skipping incompatible /usr/X11R6/lib/libX11.so when searching for -lX11
/usr/bin/ld: skipping incompatible /usr/X11R6/lib/libX11.a when searching for -lX11
/usr/bin/ld: cannot find -lX11
collect2: ld returned 1 exit status

________________________________________________________________

Specs:

AMD64
2.6.11-1.1369_FC4 x86_64 GNU/Linux


C program sourcce code
____________________________________________________________
test.c
____________________________________________________________
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>

int main(int argc, char* argv[]) {
Display *dpy;
dpy = XOpenDisplay(NULL);

if (argc!=2) {
printf("This program takes a single keysym name (such as A or U0041) as an argument\n");
return 1;
}

KeySym sym = XStringToKeysym(argv[1]);

int min, max, numcodes;
XDisplayKeycodes(dpy,&min,&max);
KeySym *keysym;
keysym = XGetKeyboardMapping(dpy,min,max-min+1,&numcodes);
keysym[(max-min-1)*numcodes]=sym;
XChangeKeyboardMapping(dpy,min,numcodes,keysym,(max-min));
XFree(keysym);
XFlush( dpy );

KeyCode code = XKeysymToKeycode(dpy,sym);

XTestFakeKeyEvent(dpy, code, True, 1);
XTestFakeKeyEvent(dpy, code, False, 1);

XFlush( dpy );

XCloseDisplay( dpy );

return 0;
}

_______________________________________________________________

Last edited by nawin_g; 04-23-2006 at 02:43 AM.
 
Old 04-23-2006, 02:53 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
It sounds like 32-bit/64-bit library incompatibilities.

You can build and execute either 32- or 64-bit apps on your box; but it sounds like you're inadvertantly mixing/matching 32- and 64-bit binaries together.

You can use the "file" command to see whether a given .so shared library is 32- or 64- bit; you can use the "-L" flag and/or modify your gcc flags to link and/or compile 32 or 64 bit executables (as you choose).

I'd suggest creating a tiny "hello world" first. Satisfy yourself that you can create and run either a 32-bit or a 64-bit executable. Then I'd check whether your Xlib development package is 32-bit or 64-bit (I'll wager you have both, in parallel directories). Finally, I'd modify your build switches to explicitly specify either one or the other environment, for both compile and link.

'Hope that helps .. PSM
 
Old 04-23-2006, 12:01 PM   #3
nawin_g
LQ Newbie
 
Registered: Nov 2005
Posts: 19

Original Poster
Rep: Reputation: 0
kinda of confused but will try wat all u suggested..tq
 
  


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 compiling gcc 3.3.6 with 64bit gcc 4.0.3 cs-cam Linux - Software 0 04-22-2006 05:20 AM
best options for gcc under athlon64 exodist Linux - Hardware 2 12-17-2004 03:21 PM
GCC compiler options???!! Umanga Linux - Newbie 1 10-08-2004 03:16 AM
Kernel compiling: gcc-3.3 is 586, should be gcc-3.3 386 Erik Plaggenmar Linux - Software 0 10-01-2004 11:38 AM
Various Compiling Errors (GCC compiling Openal, GUIlib, xmms-wma) gregorya Linux - Software 2 08-27-2004 05:03 AM

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

All times are GMT -5. The time now is 09:43 PM.

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