Hallo,
ich versuche mich gerade ein bisschen mit C. Leider bringt der Compiler
mit -W -Wall ein [segmention fault]. Ich habe wohl irgendwo was falsch
gemacht. Ich habe versucht ein bestehendes Programm um die
XGetInputFocus() Funktion zu erweitern. Dabei muss ich etwas übersehen
haben. Ich poste einfach mal den Quelltext und den Error:
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <string.h>
int main (int argc, char *argv[]) {
Display *display;
Window *focus_return;
int *revert_to_return;
int i;
if (argc<3) {
printf("usage: ./sendkey key1 key2 key3 etc.\n\n");
return(1);
}
if ((display = XOpenDisplay(NULL)) == NULL)
{
printf("Unable to open display\n");
return 1;
}
XGetInputFocus(display, focus_return,revert_to_return);
for (i=3; i<argc; ++i) {
XEvent ev;
KeySym key;
ev.xkey.type=KeyPress;
ev.xkey.window=(int)focus_return;
ev.xkey.root=ev.xkey.subwindow=None;
ev.xkey.time=0;
ev.xkey.x=ev.xkey.y=ev.xkey.x_root=ev.xkey.y_root=0;
ev.xkey.state=0;
key=XStringToKeysym(argv[i]);
ev.xkey.keycode=XKeysymToKeycode(display, key);
ev.xkey.same_screen=True;
XSendEvent(display, (int)focus_return, True, KeyPressMask, &ev);
ev.type=KeyRelease;
XSendEvent(display, (int)focus_return, True, KeyReleaseMask, &ev);
}
XCloseDisplay(display);
return(0);
}
Error:
collect2: ld terminated with signal 11 [Segmentation fault]
sendkey(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../crt1.o(.rodata+0x0):../sysdeps/i386/elf/start.S:65:
first defined here
sendkey(.data+0x4): In function `__data_start':
: multiple definition of `__dso_handle'
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/crtbegin.o(.data+0x0): first
defined here
sendkey(.init+0x0): In function `_init':
/tmp/glibc-2.3.5/build-glibc-2.3.5/csu/crti.S:35: multiple definition of `_init'
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../crti.o(.init+0x0):/tmp/glibc-2.3.5/build-glibc-2.3.5/csu/crti.S:12:
first defined here
sendkey(.text+0x0): In function `_start':
../sysdeps/i386/elf/start.S:65: multiple definition of `_start'
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../crt1.o(.text+0x0):../sysdeps/i386/elf/start.S:65:
first defined here
sendkey(.text+0xc4): In function `main':
: multiple definition of `main'
/tmp/cc6jfdFj.o(.text+0x0): first defined here
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../../i486-slackware-linux/bin/ld:
Warning: size of symbol `main' changed from 367 in /tmp/cc6jfdFj.o to 344 in
sendkey
sendkey(.fini+0x0): In function `_fini':
/tmp/glibc-2.3.5/build-glibc-2.3.5/csu/crti.S:51: multiple definition of `_fini'
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../crti.o(.fini+0x0): first
defined here
sendkey(*ABS*+0x8049974): In function `__init_array_start':
send.c: multiple definition of `_GLOBAL_OFFSET_TABLE_'
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../crt1.o(.got.plt+0x0):../sysdeps/i386/elf/start.S:65:
first defined here
sendkey(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../crt1.o(.rodata+0x4):../sysdeps/i386/elf/start.S:71:
first defined here
sendkey(.data+0x0): In function `__data_start':
: multiple definition of `__data_start'
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../crt1.o(.data+0x0):../sysdeps/i386/elf/start.S:65:
first defined here
/usr/lib/gcc-lib/i486-slackware-linux/3.3.6/../../../crt1.o(.dynamic+0x0):../sysdeps/i386/elf/start.S:65:
multiple definition of `_DYNAMIC'
MfG
Bernhard
--
----------------------------------------------------------------------------
PUG - Penguin User Group Wiesbaden - http://www.pug.org