I wrote this code:
#include <libyahoo2/yahoo2.h>
#include <libyahoo2/yahoo2_callbacks.h>
int main() {
int id ;
char username[255] = "slam";
char password[255] = "ss" ;
id = yahoo_init(username, password);
enum yahoo_status mYahoo ;
mYahoo = YAHOO_STATUS_AVAILABLE ;
yahoo_login(id , mYahoo );
return 0;
}
Compile it, gcc -l yahoo2 y.c -o yahoo
and run it with ./yahoo
gives me a error: Segmentation fault
(gdb) run
Program received signal SIGSEGV, Segmentation fault.
0x001379b1 in yahoo_login (id=1, initial=0) at libyahoo2.c:1735
line 1735 code is:
tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id,
host, yss->pager_port, yahoo_connected, ccd, 0);
and see this :
(gdb) list YAHOO_CALLBACK
Function "YAHOO_CALLBACK" not defined.
How do I debug this?
Execute these commands:
My guess would be that one or both of the above commands will fail, because
yd
oryss
is NULL.If so, the problem is earlier in libyahoo2.c, and it (apparently) doesn't check for errors properly.
The reason you can't
list YAHOO_CALLBACK
is most likely that it is a macro. Look inlibyahoo2/yahoo2_callbacks.h
-- it's very likely to be defined there.Also, your link command line:
is totally bogus. Correct command line should be:
You may want to read this explanation to understand why order of sources and libraries on command line matters.