Is it possible to make a shared library in which exist some function that are not implemented?
I'l like to make a shared library testDele.so and leave some of the functions in the testDele.so to be implimented by other people for example:
- library provider make the files:
====== testDele.c ==============
#include <stdlib.h>
#include "testDele.h"
const DELE * DELE_Init( void * udata)
{
DELE * hnd = (DELE *) malloc(sizeof(DELE));
hnd->udata = udata;
hnd->fun = &priFun;
return hnd;
}
========== testDele.h ==============
extern int priFun(int a);
typedef int (*DELE_FUN)(int a);
typedef struct _dele
{
void * udata;
DELE_FUN fun;
} DELE ;
const DELE * DELE_Init( void * udata);
- USER-B implements the files
====== testDeleImp.c ==============
#inlucde "testDele.h"
#include <stdio.h>
int priFun(int a)
{
printf("testDele priFun:a=%d\n",a);
return 1;
}
====== testDeleMain.c =============
#include "testDele.h"
int main()
{
DELE * dele = DELE_Init(NULL);
dele->fun(20);
free (dele);
return 1;
}
then when I (shared library provider) compile the shared library
% gcc -shared -o libtestDele.so -fPIC testDele.c
the following error occured
================================================
Undefined symbols:
"_priFun", referenced from:
_priFun$non_lazy_ptr in cceJPWAA.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I know this error is caused by the un-implemented function priFunc. But is there any parameters of gcc to prevent from linking the undefined symbols?
thanks a lot.