# Problem with compiling MOTP @ FreeBSD12.



## cr4sh (Apr 25, 2020)

Hello. I try to http://motp.sourceforge.net/pam_mobile_otp-0.6.2.tgz compile in FreeBSD 12.

I try to compile it with GCC, i get :


```
gcc -fPIC -D_REENTRANT -c pam_mobile_otp.c

pam_mobile_otp.c: In function 'otp':

pam_mobile_otp.c:134:5: warning: implicit declaration of function 'md5_calc' [-Wimplicit-function-declaration]

  134 |     md5_calc ( md5sum, buffer, strlen(buffer) );

      |     ^~~~~~~~

pam_mobile_otp.c: In function 'pam_sm_chauthtok':

pam_mobile_otp.c:425:53: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

  425 |       retval = pam_set_data (pamh, "motp-position", (void *)pos, NULL);

      |
```
 
And then


```
/usr/local/bin/ld -G -z defs -o pam_mobile_otp.so pam_mobile_otp.o -lpam -lc -lmd5

/usr/local/bin/ld: cannot find -lmd5
```

Anyone can help me with it ?
Best regards.


----------



## memreflect (Apr 26, 2020)

After unpacking the tarball, it appears to come with two makefiles: one for Solaris and the other for Linux.  Simply put, you're compiling using Makefile.Solaris instead of Makefile.

Before you proceed, however, what is your use case?  From the description of the file on the home page:


> Sebastian Korff wrote a PAM module for Linux and Solaris that can be used for login authentication locally without a RADIUS server.



If all you're doing is logging into a server (locally or remotely), there are existing packages like security/pam_google_authenticator that you can install and configure without needing to compile anything (unless you prefer compiling from ports, but even that would work better here due to proper integration with PAM on FreeBSD).  After that, you'd simply pair it with well-known mobile device apps such as Authy and Google Authenticator.  For more information about it, see the README.md on GitHub.


----------



## cr4sh (Apr 26, 2020)

Hello. Thanks memreflect for answer. Im using Makefile.Solaris. All the time GNU ld can't find -lmd5 ;/
I use motpd for years, and i dont want to change that.

Best regards.


----------



## memreflect (Apr 26, 2020)

cr4sh said:


> Hello. Thanks memreflect for answer. Im using Makefile.Solaris. All the time GNU ld can't find -lmd5 ;/
> I use motpd for years, and i dont want to change that.


I understand.  Just thought I'd mention the alternatives.  I hope it works for you!


----------



## cr4sh (Apr 26, 2020)

memreflect said:


> I understand.  Just thought I'd mention the alternatives.  I hope it works for you!


Thanks 
Im still searching why LD not see this md5 ;/


----------



## memreflect (Apr 26, 2020)

cr4sh said:


> Thanks
> Im still searching why LD not see this md5 ;/


Sorry for not being clearer in my previous messages.  You are receiving a linker (ld) error because you are using the wrong makefile.  Solaris has a md5 library (-lmd5), so Makefile.Solaris will work only on Solaris.  The regular Makefile compiles its own md5.c source file since there is no md5 library.  Use Makefile, not Makefile.Solaris .


----------



## cr4sh (Apr 26, 2020)

memreflect said:


> Sorry for not being clearer in my previous messages.  You are receiving a linker (ld) error because you are using the wrong makefile.  Solaris has a md5 library (-lmd5), so Makefile.Solaris will work only on Solaris.  The regular Makefile compiles its own md5.c source file since there is no md5 library.  Use Makefile, not Makefile.Solaris .


Thanks for help! That was this... i dont know why i try to build Solaris.

All is ok. Thank You one more time.


----------

