Re: Linking Shared/Static library in Freeradius Module

2011-12-08 Thread Mustafa Reşit Şahin

Hello,

I will try to explain what i am trying to achive.

I am developing a freeradius module called rlm_itap. This module uses a 
shared library called print.so (a library i use for test purposes.). 
There is only one procedure in the library and it is called : myprint() 
. I am able to run freeradius server with my own module :


$ radiusd -X

I send a test message with

$ radtest testuser pass localhost 0  testing123


If i do not use myprint() function in my own module everything works 
fine and  i am able to receive the incomming message:


+- entering group authorize {...}
++[preprocess] returns ok
ITAP: Received auth message  =*My own debug msg*

But when i use the method myprint() from the library print.so , i get 
the error when i run the server and send a message with radtest :


/# Executing section authorize from file 
/usr/local/etc/raddb/sites-enabled/default

+- entering group authorize {...}
++[preprocess] returns ok
ITAP: Received auth message
/libexec/ld-elf.so.1: 
/usr/local/lib/freeradius-2.1.10/rlm_itap-2.1.10.so: *Undefined symbol 
myprint*/




So this is the problem i am having. After your email i started to use 
autoconf and it is easier than writing my own makefile. But i am still 
not able to resolve this problem. As far as i understand freeradius is 
not able to see find print.so library. I have to find a way to show the 
server this library


I prepare my module as :

$ autoconf
$ ./configure
$ gmake clean
$ gmake
$ gmake install


Here is some more information and my makefiles:


*$ gmake *

[root@vm1 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/rlm_itap]# 
gmake

for x in .libs/* rlm_itap.la; do \
rm -rf 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/lib/$x; 
\
ln -s 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/rlm_itap/$x 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/lib/$x; 
\

done
[root@vm1 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/rlm_itap]# 
gmake clean
[root@vm1 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/rlm_itap]# 
gmake
/usr/local/bin/libtool --mode=compile cc  -O2 -pipe -I/usr/local/include 
-L/usr/local/lib -DHAVE_LT_DLADVISE_INIT -DHAVE_LT_DLADVISE_INIT 
-fno-strict-aliasing -pthread -Wall -D_GNU_SOURCE -DNDEBUG 
-I/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src  
-I/usr/include -I/home/resit/radius/include/ -c rlm_itap.c
libtool: compile:  cc -O2 -pipe -I/usr/local/include -L/usr/local/lib 
-DHAVE_LT_DLADVISE_INIT -DHAVE_LT_DLADVISE_INIT -fno-strict-aliasing 
-pthread -Wall -D_GNU_SOURCE -DNDEBUG 
-I/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src 
-I/usr/include -I/home/resit/radius/include/ -c rlm_itap.c  -fPIC -DPIC 
-o .libs/rlm_itap.o
libtool: compile:  cc -O2 -pipe -I/usr/local/include -L/usr/local/lib 
-DHAVE_LT_DLADVISE_INIT -DHAVE_LT_DLADVISE_INIT -fno-strict-aliasing 
-pthread -Wall -D_GNU_SOURCE -DNDEBUG 
-I/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src 
-I/usr/include -I/home/resit/radius/include/ -c rlm_itap.c -o rlm_itap.o 
/dev/null 21

/usr/local/bin/libtool --mode=link cc -release 2.1.10 \
-module -export-dynamic -rpath=/usr/lib:/usr/local/lib  -o 
rlm_itap.la \
-rpath /usr/local/lib/freeradius-2.1.10 rlm_itap.lo rlm_itap.c 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/lib/libfreeradius-radius.la 
-lc -L/home/resit/radius/lib/ /home/resit/radius/lib/print.so
libtool: link: cc -shared  .libs/rlm_itap.o   -Wl,-rpath 
-Wl,/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/lib/.libs 
-Wl,-rpath -Wl,/usr/local/lib/freeradius-2.1.10 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/lib/.libs/libfreeradius-radius.so 
-L/usr/local/lib -pthread -L/home/resit/radius/lib/  -pthread   -pthread 
-Wl,-soname -Wl,rlm_itap-2.1.10.so -o .libs/rlm_itap-2.1.10.so
libtool: link: (cd .libs  rm -f rlm_itap.so  ln -s 
rlm_itap-2.1.10.so rlm_itap.so)

libtool: link: ar cru .libs/rlm_itap.a  rlm_itap.o
libtool: link: ranlib .libs/rlm_itap.a
libtool: link: ( cd .libs  rm -f rlm_itap.la  ln -s 
../rlm_itap.la rlm_itap.la )

for x in .libs/* rlm_itap.la; do \
rm -rf 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/lib/$x; 
\
ln -s 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/rlm_itap/$x 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/lib/$x; 
\

done






*$ gmake install :

*[root@vm1 
/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/rlm_itap]# 
gmake install
gmake[1]: Entering directory 
`/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/rlm_itap'

touch .
gmake[1]: Leaving directory 
`/usr/ports/net/freeradius2/work/freeradius-server-2.1.10/src/modules/rlm_itap'

if [ xrlm_itap != x ]; then \
/usr/local/bin/libtool --mode=install 

Re: Linking Shared/Static library in Freeradius Module

2011-12-08 Thread Fajar A. Nugraha
2011/12/8 Mustafa Reşit Şahin resitsa...@gmail.com:
 My makefile.in file

 RLM_LIBS    = @itap_ldflags@ -L/home/resit/radius/lib/
 /home/resit/radius/lib/print.so

shouldn't it be -lprint instead of /home/resit/radius/lib/print.so?

-- 
Fajar

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


Re: Linking Shared/Static library in Freeradius Module

2011-12-08 Thread Mustafa Reşit Şahin

Well, yes it seems to be problem.

But there is one more thing. The libprint.so should reside in : /usr/lib 
or /usr/local/lib/



Considering my experience with writing a module for freeradius i think 
wiki page for module creation can be updated with following info:


1) Mentioning autoconf procedure.

autoconf.in makefile.in files.
running autoconf
running ./configure

building:
gmake clean  gmake  gmake install



Regards



On 12/08/2011 04:58 PM, Fajar A. Nugraha wrote:

2011/12/8 Mustafa Reşit Şahinresitsa...@gmail.com:

My makefile.in file
RLM_LIBS= @itap_ldflags@ -L/home/resit/radius/lib/
/home/resit/radius/lib/print.so

shouldn't it be -lprint instead of /home/resit/radius/lib/print.so?




--
Mustafa Reşit Şahin
Endersys İş Tel: 0216 470 94 23 Dahili:306
Cep Tel:0507 707 68 12

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


Re: Linking Shared/Static library in Freeradius Module

2011-12-08 Thread Alan DeKok
Mustafa Reşit Şahin wrote:
 Considering my experience with writing a module for freeradius i think
 wiki page for module creation can be updated with following info:
 
 1) Mentioning autoconf procedure.

  No.  Autoconf is insane and complicated.  There is no reason why
normal people need to use it.  I use it, and look how I turned out...

  For building modules, it should be VERY easy.  See the examples in
rlm_example.  Change the names, add header files and libraries.  That's it.

  Many other people have done this, and it works.

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


Re: Linking Shared/Static library in Freeradius Module

2011-12-08 Thread Alan DeKok
Mustafa Reşit Şahin wrote:
...
 But when i use the method myprint() from the library print.so , i get
 the error when i run the server and send a message with radtest :
...
 -lc -L/home/resit/radius/lib/ /home/resit/radius/lib/print.so

  This is a dynamic linker problem.  You've put the library where ld.so
cannot find it.  Put the file into a normal directory, where the linker
can find it.

  This isn't a FreeRADIUS problem.

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


Re: Linking Shared/Static library in Freeradius Module

2011-12-07 Thread Mustafa Reşit Şahin

I am trying to use   src/modules/rlm_example/Makefile using configure files.

In this makefile stated :


# The RLM_LIBS definition should list ALL required libraries.
# These libraries really should be pulled from the 'config.mak'
# definitions, if at all possible.  These definitions are also
# echoed into another file in ../lib, where they're picked up by
# ../main/Makefile for building the version of the server with
# statically linked modules.  Get it from autoconf.
#


Which file mentioned with These definitions are also # echoed into 
another file in ../lib, ?


I could not find this file. As far as i understand, i have to add 
shared/static libraries ( which i link from my new module ) into this 
file . So freeradius can find them.


I consider this because i get the error :

/libexec/ld-elf.so.1: 
/usr/local/lib/freeradius-2.1.10/rlm_itap-2.1.10.so: Undefined symbol 
sendiccmsg


when i run radiusserver and send an autorization message to server.





On 12/06/2011 06:00 PM, Alan DeKok wrote:

Mustafa Reşit Şahin wrote:

I have followed the steps here :

http://wiki.freeradius.org/Modules2#Testing

   Well, it's wrong.  I'm not sure it was ever correct.  I've deleted
that example from the Wiki.

   Look at src/modules/rlm_example/Makefile.  It works, and is correct.
Edit it to build your module.  It's a *lot* simpler.

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



--
Mustafa Reşit Şahin
Endersys İş Tel: 0216 470 94 23 Dahili:306
Cep Tel:0507 707 68 12

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


Re: Linking Shared/Static library in Freeradius Module

2011-12-07 Thread Alan DeKok
Mustafa Reşit Şahin wrote:
 Which file mentioned with These definitions are also # echoed into
 another file in ../lib, ?

  Files automatically produced by the builds.

 I could not find this file. As far as i understand, i have to add
 shared/static libraries ( which i link from my new module ) into this
 file . So freeradius can find them.

  No.  You just add them in the RLM_LIBS line.

 I consider this because i get the error :
 
 /libexec/ld-elf.so.1:
 /usr/local/lib/freeradius-2.1.10/rlm_itap-2.1.10.so: Undefined symbol
 sendiccmsg
 
 when i run radiusserver and send an autorization message to server.

  You probably need to re-build radiusd, too.

  Or... *show* what you did.  This isn't hard.

  The current build process *can* link to static libraries, and *does*
link to static libraries, and *works* when modules are linked to static
libraries.  If you follow the examples, it *should* work.

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


Linking Shared/Static library in Freeradius Module

2011-12-06 Thread Resit Sahin
Hello,

I am writing a FreeRadius (Version 2) module for version Freeradius 2.1.10
. The module works fine. When i want to link a shared/static library from
the Makefile of the module i get errors.

I link to a static library and i run radius server with the module (
radiusd -X) then i get the error:

/usr/local/etc/raddb/radiusd.conf[665]: Failed to link to module
'rlm_itap': file not found

makefile of the freeradius module :

*VERS = 2.1.10
CFLAGS  =  -DNDEBUG -Wall -I/usr/include \
   -I/usr/ports/net/freeradius2/work/freeradius-server-$(VERS)/src
LIBS=  -lc -L. icc-wrapper.a
ALL:rlm_itap.o rlm_itap-$(VERS).so*


rlm_itap is the name of my module. When i remove *icc-wrapper.a ,
everything works fine.


*For the shared library case. Everything works fine until the function from
the shared library is called inside the module. I got the error:

/libexec/ld-elf.so.1: /usr/local/lib/freeradius-2.1.10/rlm_itap.so:
Undefined symbol sendiccmsg

in that case. sendiccmsg is the only function i have in my shared library.

The makefile of the freeradius module:

VERS = 2.1.10

CFLAGS  =  -DNDEBUG -Wall -I/usr/include \
   -I/usr/ports/net/freeradius2/work/freeradius-server-$(VERS)/src

LIBS=  -lc icc-wrapper.so

ALL:rlm_itap.o rlm_itap-$(VERS).so

rlm_itap.o:rlm_itap.c
cc -g -fPIC -DPIC -c $(CFLAGS) rlm_itap.c

rlm_itap-$(VERS).so:rlm_itap.o
cc -g -shared -Wl,-soname,rlm_itap-$(VERS).so \
   -o rlm_itap-$(VERS).so rlm_itap.o $(LIBS)

install:ALL
install rlm_itap-$(VERS).so /usr/local/lib/freeradius-$(VERS)
ln -fs rlm_itap-$(VERS).so /usr/local/lib/freeradius-$(VERS)/rlm_itap.so

clean:
rm rlm_itap*.o rlm_itap*.so



The static/shred library i am using is compiled as a C++ library with
extern C in front of function definitions.


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


Re: Linking Shared/Static library in Freeradius Module

2011-12-06 Thread Alan DeKok
Resit Sahin wrote:
 I am writing a FreeRadius (Version 2) module for version Freeradius
 2.1.10 . The module works fine. When i want to link a shared/static
 library from the Makefile of the module i get errors.

  You didn't follow the FreeRADIUS build process.

 makefile of the freeradius module :
 
 /VERS = 2.1.10
 CFLAGS  =  -DNDEBUG -Wall -I/usr/include \
-I/usr/ports/net/freeradius2/work/freeradius-server-$(VERS)/src
 LIBS=  -lc -L. icc-wrapper.a
 ALL:rlm_itap.o rlm_itap-$(VERS).so/

  Uh... *why* did you do this?

  The server ships with *many* examples of building modules.  The build
system for the server takes care of all of the necessary magic to make
it Just Work.

  By creating your own Makefile you've done more work than necessary,
and ensured that the resulting module won't work with FreeRADIUS.

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


Re: Linking Shared/Static library in Freeradius Module

2011-12-06 Thread Mustafa Reşit Şahin

I have followed the steps here :

http://wiki.freeradius.org/Modules2#Testing

The makefile is almost the same with the makefile there.

It is recommended to use your own make file in the wiki entry

My module works fine without linking libraries. The problems arise when 
i try to link external libraries.


Resit


On 12/06/2011 05:36 PM, Alan DeKok wrote:

Resit Sahin wrote:

I am writing a FreeRadius (Version 2) module for version Freeradius
2.1.10 . The module works fine. When i want to link a shared/static
library from the Makefile of the module i get errors.

   You didn't follow the FreeRADIUS build process.


makefile of the freeradius module :

/VERS = 2.1.10
CFLAGS  =  -DNDEBUG -Wall -I/usr/include \
-I/usr/ports/net/freeradius2/work/freeradius-server-$(VERS)/src
LIBS=  -lc -L. icc-wrapper.a
ALL:rlm_itap.o rlm_itap-$(VERS).so/

   Uh... *why* did you do this?

   The server ships with *many* examples of building modules.  The build
system for the server takes care of all of the necessary magic to make
it Just Work.

   By creating your own Makefile you've done more work than necessary,
and ensured that the resulting module won't work with FreeRADIUS.

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



--
Mustafa Reşit Şahin
Endersys İş Tel: 0216 470 94 23 Dahili:306
Cep Tel:0507 707 68 12

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


Re: Linking Shared/Static library in Freeradius Module

2011-12-06 Thread Alan DeKok
Mustafa Reşit Şahin wrote:
 I have followed the steps here :
 
 http://wiki.freeradius.org/Modules2#Testing

  Well, it's wrong.  I'm not sure it was ever correct.  I've deleted
that example from the Wiki.

  Look at src/modules/rlm_example/Makefile.  It works, and is correct.
Edit it to build your module.  It's a *lot* simpler.

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


Re: Linking Shared/Static library in Freeradius Module

2011-12-06 Thread Omer Faruk SEN
2.1.10 yerine en son surum olan

2.1.12 kullanirsan daha yararli (http://freeradius.org/ dan indirebilirsin)



2011/12/6 Mustafa Reşit Şahin resitsa...@gmail.com

 I have followed the steps here :

 http://wiki.freeradius.org/**Modules2#Testinghttp://wiki.freeradius.org/Modules2#Testing

 The makefile is almost the same with the makefile there.

 It is recommended to use your own make file in the wiki entry

 My module works fine without linking libraries. The problems arise when i
 try to link external libraries.

 Resit



 On 12/06/2011 05:36 PM, Alan DeKok wrote:

 Resit Sahin wrote:

 I am writing a FreeRadius (Version 2) module for version Freeradius
 2.1.10 . The module works fine. When i want to link a shared/static
 library from the Makefile of the module i get errors.

   You didn't follow the FreeRADIUS build process.

  makefile of the freeradius module :

 /VERS = 2.1.10
 CFLAGS  =  -DNDEBUG -Wall -I/usr/include \
-I/usr/ports/net/freeradius2/**work/freeradius-server-$(VERS)
 **/src
 LIBS=  -lc -L. icc-wrapper.a
 ALL:rlm_itap.o rlm_itap-$(VERS).so/

   Uh... *why* did you do this?

   The server ships with *many* examples of building modules.  The build
 system for the server takes care of all of the necessary magic to make
 it Just Work.

   By creating your own Makefile you've done more work than necessary,
 and ensured that the resulting module won't work with FreeRADIUS.

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



 --
 Mustafa Reşit Şahin
 Endersys İş Tel: 0216 470 94 23 Dahili:306
 Cep Tel:0507 707 68 12


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

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