[Spread-users] Undefined reference to functions error

Zahir Koradia zahir.koradia at gmail.com
Mon Aug 21 04:28:20 EDT 2006

I am new to Spread and was trying to write a dummy program just to get
a feel of it.
I go the following error:
undefined reference to `_SP_connect'
undefined reference to `_SP_join'
undefined reference to `_SP_leave'
undefined reference to `_SP_disconnect'
collect2: ld returned 1 exit status

My header files are present in /usr/local/include. My code is present below:

// Program to basically test sending and receiving messages
// We will create two programs and have one send message to the other
// and the second one will send a message only on received a message
from teh first.
//this program will send a message on prompt.

#ifdef __cplusplus
extern "C"
#include <stdio.h>
#include <stdlib.h>
#include <sp.h>
int main()
  int ret;
  char priv_grp[MAX_GROUP_NAME];
  mailbox *sender_box;
  sender_box = (mailbox *)malloc(sizeof(mailbox));
  ret = SP_connect("4803 at localhost", "spread_sender", 0, 1,
sender_box, priv_grp);
  if(ret == ACCEPT_SESSION)
    printf("Connect succeeded! Joining test_grp....\n");
    printf("Connect failed!\n");
    return 0;
  ret = SP_join(*sender_box, "test_grp");
  if(ret == 0)
    printf("Join succeeded! Press any keey to send a message to the
    printf("Join failed!\n");
    return 0;

  SP_leave(*sender_box, "test_grp");
  return 0;

#ifdef __cplusplus

I have tried using g++ also but does not help. I have also tried using
a .c file with the same code but it dint work. I know this is not
directly related to spread but I would appreciate if someone helped me

Zahir koradia

More information about the Spread-users mailing list