Original Post
ok, im working on an irc bot system that runs almost entirely off of customizable modules. I want it to be set up so that whenever you want to add another module or change a previous one you dont have to recompile the whole bot. My intent is to build something that works similar to the way firefox extensions work. So instinctively i turn to dynamic linking, but i remembered that i have 0 experience in working with dynamic linking. My problem is that all of the external functions i try to call from my modules are undefined (this makes perfect sense to me, but i dont get how to make it work like i want it to). here, code talks best a simple module: khook.h (my pathetic attempt to solve the problem) The failure: ideas, sugestions, and bitch slaps of obvious truth are all welcome <3 Thetan
#include "../khook.h"
void hookAct(struct ircHandle *ih, struct ircHeader *ph)
{
if(ph->message[0] == '+' && strncmp(&(ph->message[1]), "act", 3) == 0)
IRCAction(ih, ph->channel, &(ph->message[5])); // the function that exists in the program loading this module
}
struct ircHandle
{
int port, sock;
char nick[50];
};
struct ircHeader
{
char *raw;
char *nick;
char *name;
char *vhost;
char *channel;
char *type;
char *target;
char *message;
};
// me attempting to extern the outside functions
void IRCUser(struct ircHandle*, char*);
void IRCNick(struct ircHandle*, char*);
int IRCOpen(struct ircHandle*, char*, int, char*);
char IRCGetChar(struct ircHandle*);
char* IRCGetHeader(struct ircHandle*);
struct ircHeader* IRCGetParsedHeader(struct ircHandle*);
void IRCHeaderFree(struct ircHeader*);
int IRCPing(struct ircHandle*, struct ircHeader*);
void IRCNotice(struct ircHandle*, char*, char*);
void IRCKick(struct ircHandle*, char*, char*, char*);
void IRCPrivmsg(struct ircHandle*, char*, char*);
void IRCAction(struct ircHandle*, char*, char*);
void IRCJoin(struct ircHandle*, char*);
void IRCQuit(struct ircHandle*, char*);
[r3d@localhost PRIVMSG]$ gcc -fPIC Act.c
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
/tmp/ccsuf1o1.o(.text+0x55): In function `hookAct':
: undefined reference to `IRCAction'
collect2: ld returned 1 exit status
[r3d@localhost PRIVMSG]$