View Single Post
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#50
OMG
FORGET TO LINK "pidgin"
NOW THE FUNCTIONS WORK FINE
IGNORE THE REST OF THE POST xD
--------------------------------------------


i found some interesting functions in the "account.h" file of libpurple.
and i tried to use them but i get an error when trying to compile the code.

include:
Code:
#include <libpurple/account.h>
(the file is in place and found by the compiler)

example of function declaration in account.h:
Code:
const char *purple_account_get_alias(const PurpleAccount *account);
(do i have to do something more then just calling the function in my code?)

callback with the functions declared in account.h:
Code:
/* Signal callback handling routing */
void received_im_msg_cb (DBusGProxy *purple_proxy, int account_id, 
                         const char *sender, const char *message, 
                         int conv_id, unsigned int flags,
                         gpointer user_data)
{

/* need to inlcude "account.h" for following functions */
const PurpleAccount *account;
const char *alias;
const char *icon_path;
const char *protocol;

// PurpleAccount *purple_accounts_find_any(const char *name, const char *protocol);
// PurpleAccount *purple_accounts_find_connected(const char *name, const char *protocol);
account = purple_accounts_find(sender, NULL);

/* get the alias */
alias = purple_account_get_alias(account); 
/* get the icon path */
icon_path = purple_account_get_buddy_icon_path(account); 
/* get the protocol name */
protocol = purple_account_get_protocol_name(account);

    g_print("Account %d receives msg \"%s\" from %s\n",   
            account_id, message, sender);
    
    g_print("Alias %s, Path %s, Protocol %s", alias, icon_path, protocol);
}
(am i declaring my variables (account, alias, icon_path, protocol) in the right way?)

my compiler command:
Code:
sudo gcc -MMD -Wall -ggdb -O `pkg-config --cflags dbus-1 glib-2.0 dbus-glib-1` `pkg-config --libs dbus-1 glib-2.0 dbus-glib-1` marshal.c pidginnotifyd.c -o pidginnotifyd
(am i missing something here? like linking the pidgin-dev lib..?!)

and this is the error i get:
Code:
/tmp/ccVoXEPd.o: In function `received_im_msg_cb':
/home/b666m/pidgin/pidginnotifyd.c:37: undefined reference to `purple_accounts_find'
/home/b666m/pidgin/pidginnotifyd.c:40: undefined reference to `purple_account_get_alias'
/home/b666m/pidgin/pidginnotifyd.c:42: undefined reference to `purple_account_get_buddy_icon_path'
/home/b666m/pidgin/pidginnotifyd.c:44: undefined reference to `purple_account_get_protocol_name'
collect2: ld returned 1 exit status
(what is meant by "undefined reference to"? the function is declared in account.h)

help, please (:

---------------------------------------------------

the correct compiler command:
Code:
sudo gcc -MMD -Wall -ggdb -O `pkg-config --cflags dbus-1 glib-2.0 dbus-glib-1 pidgin` `pkg-config --libs dbus-1 glib-2.0 dbus-glib-1 pidgin` marshal.c pidginnotifyd.c -o pidginnotifyd

Last edited by b666m; 2010-06-24 at 14:17.