Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > errors due to library functions being undefined,

Reply
Thread Tools

errors due to library functions being undefined,

 
 
alex.don253@gmail.com
Guest
Posts: n/a
 
      12-10-2012
I am trying to complile a program in C using eclipse and I am having this error:

undefined reference to `XTestFakeKeyEvent'

i used
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <iostream>

Could help me to solve that issue?
thanks
 
Reply With Quote
 
 
 
 
Noob
Guest
Posts: n/a
 
      12-10-2012
alex.don253 wrote:

> undefined reference to `XTestFakeKeyEvent'


FAQ 13.25
http://c-faq.com/lib/extlibs.html
-lXtst seems like a good candidate.

> #include <X11/keysym.h>
> #include <X11/Xlib.h>


(Please note that this discussion is off-topic)
According to the man page, you might need to
#include <X11/extensions/XTest.h>
http://linux.die.net/man/3/xtestfakekeyevent

> #include <iostream>


If you want to discuss specific C++ features, you can use the
comp.lang.c++ news group.

Regards.

 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      12-10-2012
http://www.velocityreviews.com/forums/(E-Mail Removed) writes:

> I am trying to complile a program in C using eclipse and I am having this error:
>
> undefined reference to `XTestFakeKeyEvent'


This is almost certainly a link error. In other words it describes a
missing definition -- some function (XTestFakeKeyEvent) is being
referred to but it is nowhere defined.

> i used
> #include <X11/keysym.h>
> #include <X11/Xlib.h>


These things provide declarations of functions but only rarely do they
provide definitions. The definitions reside in libraries and you must
tell the linker (the part of the C compiler that puts your program
together from all it's different parts) where to find it.

On my system,using the command-line compiler gcc I just need to add a
link option like this:

$ gcc x.c -lXtst

Without that "-lXtst" (for the X11 test extension) I get the error you
report:

$ gcc x.c -lXext
/tmp/ccs8ziwK.o: In function `main':
x.c.text+0xa): undefined reference to `XTestFakeKeyEvent'
collect2: error: ld returned 1 exit status

You'll have to find out how to do this in Eclipse some other way since
I've never used it.

But there is another very important matter. As others have said, you
probably need to

#include <X11/extensions/XTest.h>

because that's where XTestFakeKeyEvent is declared. The fact that you
are not also getting the message

warning: implicit declaration of function `XTestFakeKeyEvent'

means that you have not got the warning level set high enough, or that
you are compiling in some rather permissive non-standard mode. You
should, in general, ask for all the help the compiler can give you, so I
always work with as many warnings turned on as I can stand. For
example:

$ gcc -Wall x.c
x.c: In function ‘main’:
x.c:6:6: warning: implicit declaration of function ‘XTestFakeKeyEvent’ [-Wimplicit-function-declaration]

which is something I would want to know.

> #include <iostream>


Your problem happens to be the same in C and in C++, but in general, C++
questions belong in comp.lang.c++.

> Could help me to solve that issue?
> thanks


--
Ben.
 
Reply With Quote
 
Joachim Schmitz
Guest
Posts: n/a
 
      12-10-2012
Ben Bacarisse wrote:
> (E-Mail Removed) writes:
>
>> I am trying to complile a program in C using eclipse and I am having
>> this error:
>>
>> undefined reference to `XTestFakeKeyEvent'

>
> This is almost certainly a link error. In other words it describes a
> missing definition -- some function (XTestFakeKeyEvent) is being
> referred to but it is nowhere defined.
>
>> i used
>> #include <X11/keysym.h>
>> #include <X11/Xlib.h>

>
> These things provide declarations of functions but only rarely do they
> provide definitions. The definitions reside in libraries and you must
> tell the linker (the part of the C compiler that puts your program
> together from all it's different parts) where to find it.
>
> On my system,using the command-line compiler gcc I just need to add a
> link option like this:
>
> $ gcc x.c -lXtst
>
> Without that "-lXtst" (for the X11 test extension) I get the error you
> report:
>
> $ gcc x.c -lXext
> /tmp/ccs8ziwK.o: In function `main':
> x.c.text+0xa): undefined reference to `XTestFakeKeyEvent'
> collect2: error: ld returned 1 exit status
>
> You'll have to find out how to do this in Eclipse some other way since
> I've never used it.
>
> But there is another very important matter. As others have said, you
> probably need to
>
> #include <X11/extensions/XTest.h>
>
> because that's where XTestFakeKeyEvent is declared. The fact that you
> are not also getting the message
>
> warning: implicit declaration of function `XTestFakeKeyEvent'
>
> means that you have not got the warning level set high enough, or that
> you are compiling in some rather permissive non-standard mode. You
> should, in general, ask for all the help the compiler can give you,
> so I
> always work with as many warnings turned on as I can stand. For
> example:
>
> $ gcc -Wall x.c
> x.c: In function ‘main’:
> x.c:6:6: warning: implicit declaration of function
> ‘XTestFakeKeyEvent’ [-Wimplicit-function-declaration]
>
> which is something I would want to know.
>
>> #include <iostream>

>
> Your problem happens to be the same in C and in C++,


In C++ (as well as in C99 and later) it shouldn't even compile in absence
of a declaration.
Not sure then how ther OP could have gotten a linker error?

Bye, Jojo

 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      12-10-2012
"Joachim Schmitz" <(E-Mail Removed)> writes:

> Ben Bacarisse wrote:
>> (E-Mail Removed) writes:
>>
>>> I am trying to complile a program in C using eclipse and I am having
>>> this error:
>>>
>>> undefined reference to `XTestFakeKeyEvent'

>>
>> This is almost certainly a link error. In other words it describes a
>> missing definition -- some function (XTestFakeKeyEvent) is being
>> referred to but it is nowhere defined.
>>
>>> i used
>>> #include <X11/keysym.h>
>>> #include <X11/Xlib.h>

>>
>> These things provide declarations of functions but only rarely do they
>> provide definitions. The definitions reside in libraries and you must
>> tell the linker (the part of the C compiler that puts your program
>> together from all it's different parts) where to find it.
>>
>> On my system,using the command-line compiler gcc I just need to add a
>> link option like this:
>>
>> $ gcc x.c -lXtst
>>
>> Without that "-lXtst" (for the X11 test extension) I get the error you
>> report:
>>
>> $ gcc x.c -lXext
>> /tmp/ccs8ziwK.o: In function `main':
>> x.c.text+0xa): undefined reference to `XTestFakeKeyEvent'
>> collect2: error: ld returned 1 exit status
>>
>> You'll have to find out how to do this in Eclipse some other way since
>> I've never used it.
>>
>> But there is another very important matter. As others have said, you
>> probably need to
>>
>> #include <X11/extensions/XTest.h>
>>
>> because that's where XTestFakeKeyEvent is declared. The fact that you
>> are not also getting the message
>>
>> warning: implicit declaration of function `XTestFakeKeyEvent'
>>
>> means that you have not got the warning level set high enough, or that
>> you are compiling in some rather permissive non-standard mode. You
>> should, in general, ask for all the help the compiler can give you,
>> so I
>> always work with as many warnings turned on as I can stand. For
>> example:
>>
>> $ gcc -Wall x.c
>> x.c: In function ‘main’:
>> x.c:6:6: warning: implicit declaration of function
>> ‘XTestFakeKeyEvent’ [-Wimplicit-function-declaration]
>>
>> which is something I would want to know.
>>
>>> #include <iostream>

>>
>> Your problem happens to be the same in C and in C++,

>
> In C++ (as well as in C99 and later) it shouldn't even compile in
> absence of a declaration.


There's no requirement that it shouldn't compile in C99; what's required
is that a diagnostic be issued. After that, the implementation can do
what it likes, and trying to link the problem seems to be a common
behaviour. I think the same is true of C++.

> Not sure then how ther OP could have gotten a linker error?


The real question is why the OP did not get the required diagnostic
about the missing declaration, and that is covered by my remark to the
op: "you have not got the warning level set high enough, or that you are
compiling in some rather permissive non-standard mode". For example,
gcc will give you the error if you ask for C99 mode (-std=c99 -pedantic)
or if you turn on enough warnings (-Wimplicit-function-declaration as a
minimum, but -Wall would be better).

--
Ben.
 
Reply With Quote
 
Joachim Schmitz
Guest
Posts: n/a
 
      12-10-2012
Ben Bacarisse wrote:
> "Joachim Schmitz" <(E-Mail Removed)> writes:
>
>> Ben Bacarisse wrote:
>>> (E-Mail Removed) writes:
>>>
>>>> I am trying to complile a program in C using eclipse and I am
>>>> having this error:
>>>>
>>>> undefined reference to `XTestFakeKeyEvent'
>>>
>>> This is almost certainly a link error. In other words it describes
>>> a missing definition -- some function (XTestFakeKeyEvent) is being
>>> referred to but it is nowhere defined.
>>>
>>>> i used
>>>> #include <X11/keysym.h>
>>>> #include <X11/Xlib.h>
>>>
>>> These things provide declarations of functions but only rarely do
>>> they provide definitions. The definitions reside in libraries and
>>> you must tell the linker (the part of the C compiler that puts your
>>> program together from all it's different parts) where to find it.
>>>
>>> On my system,using the command-line compiler gcc I just need to add
>>> a link option like this:
>>>
>>> $ gcc x.c -lXtst
>>>
>>> Without that "-lXtst" (for the X11 test extension) I get the error
>>> you report:
>>>
>>> $ gcc x.c -lXext
>>> /tmp/ccs8ziwK.o: In function `main':
>>> x.c.text+0xa): undefined reference to `XTestFakeKeyEvent'
>>> collect2: error: ld returned 1 exit status
>>>
>>> You'll have to find out how to do this in Eclipse some other way
>>> since I've never used it.
>>>
>>> But there is another very important matter. As others have said,
>>> you probably need to
>>>
>>> #include <X11/extensions/XTest.h>
>>>
>>> because that's where XTestFakeKeyEvent is declared. The fact that
>>> you are not also getting the message
>>>
>>> warning: implicit declaration of function `XTestFakeKeyEvent'
>>>
>>> means that you have not got the warning level set high enough, or
>>> that you are compiling in some rather permissive non-standard mode.
>>> You should, in general, ask for all the help the compiler can give
>>> you, so I
>>> always work with as many warnings turned on as I can stand. For
>>> example:
>>>
>>> $ gcc -Wall x.c
>>> x.c: In function ‘main’:
>>> x.c:6:6: warning: implicit declaration of function
>>> ‘XTestFakeKeyEvent’ [-Wimplicit-function-declaration]
>>>
>>> which is something I would want to know.
>>>
>>>> #include <iostream>
>>>
>>> Your problem happens to be the same in C and in C++,

>>
>> In C++ (as well as in C99 and later) it shouldn't even compile in
>> absence of a declaration.

>
> There's no requirement that it shouldn't compile in C99; what's
> required is that a diagnostic be issued.


Ah, yes, I seem to often confuse those 2 things

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to due with "warning LNK4075: ignoring '/INCREMENTAL' due to Fresh C++ 2 04-22-2008 09:03 PM
Drop-down lists populated twice due to page_load being processed t smccreadie ASP .Net Web Controls 0 10-27-2006 09:07 PM
Lost work due to USB flash pen not being recognised properly numberonepipboy Computer Support 1 07-15-2004 09:36 AM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM
Canon 10D's being boycotted in Korea due to major focus error issues... W6DKN Digital Photography 0 08-01-2003 08:31 AM



Advertisments