Hi,
My first guess would be to ask if you're calling a C++ method directly from C. You can link a C++ library into Freeradius, but in order to call a C++ method you have to put it inside a C wrapper function. Your code would like something like this:


interface.h
--------------
#ifdef __cplusplus
extern "C"
{
#endif

int
interfaceWrapper(int arg);

#ifdef __cplusplus
extern "C"
}
#endif

interface.cpp
----------------
#include "interface.h"
#include "C++_library.h"

int
interfaceWrapper(int arg)
{
int rc;
new yourC++object;
rc = yourC++object->method(arg);
delete yourC++object;
// or you may want to use a persistent object. Just keep a pointer to it that you can get to.
return rc;
}


Freeradius rlm_xxx.c
-------------------------
#include "interface.h"

int
xxx_authenticate // for example
{
  if (interfaceWrapper(arg) == 0)
     return RLM_MODULE_OK;
  else
     return RLM_MODULE_FAILURE;
}

This gives you an interface.o and rlm_xxx.o which must both be linked into radiusd, along with your library.

If youre already doing this, I'm not sure where the error would be coming from. You can use the "nm" command to check the symbols that are defined in your library and make sure the one you want is really there.

Dave

Htin Hlaing wrote:

Hi,

Using the suggestions and the patch on the list, I put in my C++ module
in.  That works fine.  But from the new C++ module, I need to be able to
use another third party C++ library.  There, I am having a hard time.
At this point, I configure using --with-static-modules=3Dmymodule to =
catch
the link error at compile time.  In my Makefile, I put RLM_LIBS +=3D
-lstdc++ -L/home/hhlaing/project/head/libxmlrpc++ -lXmlRpc to link in
the third party library.  I get link error saying the symbol not found;
the symbol is from the third party library.  Here is the exact error
message:

gcc .libs/radiusdS.o -g -O2 -pthread -D_THREAD_SAFE -DOPENSSL_NO_KRB5
-Wall -D_GNU_SOURCE -g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wnested-externs -W -Wredundant-decls -Wundef
-I../include -DHOSTINFO=3D\"\" -DRADIUSD_VERSION=3D\"1.0.0-pre0\" -o
.libs/radiusd radiusd.o files.o util.o acct.o nas.o log.o valuepair.o
version.o proxy.o exec.o auth.o timestr.o conffile.o modules.o modcall.o
session.o xlat.o threads.o smux.o radius_snmp.o client.o request_list.o
mainconfig.o -Wl,--export-dynamic
../modules/rlm_xmlrpc/.libs/rlm_xmlrpc.a -lstdc++
-L/home/hhlaing/project/head/libxmlrpc++ -lXmlRpc
-L/data/home/hhlaing/FreeRadius/radiusd-May-9/src/lib -lcrypt -lcipher
/data/home/hhlaing/FreeRadius/radiusd-May-9/src/lib/.libs/libradius.so
/data/home/hhlaing/FreeRadius/radiusd-May-9/libltdl/.libs/libltdl.so
-lcrypto -lssl -lcrypt -lcipher -Wl,--rpath
-Wl,/home/hhlaing/Install/FreeRadius-May-9/lib
/usr/lib/libc.so.4: warning: this program uses gets(), which is unsafe.
/usr/lib/libc.so.4: warning: mktemp() possibly used unsafely; consider
using mkstemp()
/usr/lib/libc.so.4: warning: tmpnam() possibly used unsafely; consider
using mkstemp()
/usr/lib/libc.so.4: warning: this program uses f_prealloc(), which is
not recommended.
/usr/lib/libc.so.4: warning: tempnam() possibly used unsafely; consider
using mkstemp()
../modules/rlm_xmlrpc/.libs/rlm_xmlrpc.a(rlm_xmlrpc.o): In function
`xmlrpcInstantiate(conf_part *, void **)':
/data/home/hhlaing/FreeRadius/radiusd-May-9/src/modules/rlm_xmlrpc/rlm_x
mlrpc.cpp:122: undefined reference to
`XmlRpc::XmlRpcClient::XmlRpcClient(char const *, int, char const *)'
gmake[3]: *** [radiusd] Error 1
gmake[3]: Leaving directory
`/data/home/hhlaing/FreeRadius/radiusd-May-9/src/main'


Thanks, Htin







- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to