# Asterisk: undefined reference to `crypt_r'



## for.ggame.playing (Jun 15, 2020)

I wanted to install asterisk on my FreeBSD 12.1-Release PC from asterisk source code.
I managed to install packages on /usr/src directory, however make command outputs error

```
/usr/local/bin/ld: crypt.o: in function `ast_crypt':
/usr/src/asterisk/asterisk-17.5.0/main/crypt.c:124: undefined reference to `crypt_r'
/usr/local/bin/ld: crypt.o: in function `ast_crypt_validate':
/usr/src/asterisk/asterisk-17.5.0/main/crypt.c:139: undefined reference to `crypt_r'
collect2: error: ld returned 1 exit status
gmake[2]: *** [Makefile:321: asterisk] Error 1
gmake[1]: *** [Makefile:387: main] Error 2
gmake[1]: Leaving directory '/usr/src/asterisk-17.5.0'
*** Error code 2

Stop.
```

Beneath I present `pkg info -a` in a text file and `./configure` command within the source code(to check the dependencies)


----------



## SirDice (Jun 17, 2020)

for.ggame.playing said:


> I managed to install packages on /usr/src directory


You did what? How? Why? The /usr/src/ directory contains the source code for FreeBSD itself, and nothing else belongs there.


----------



## for.ggame.playing (Jun 18, 2020)

Well, technically I had the same issue trying to install port asterisk16 from ports and I had the same issue. So I wouldn't stick to newest version and here is my problem

```
cd /usr/ports/net/asterisk16
make install clean

cdr_mysql.c:199:51: error: use of undeclared identifier 'my_bool_true'
                if (mysql_options(&mysql, MYSQL_OPT_RECONNECT, &my_bool_true) != 0) {
                                                                ^
cdr_mysql.c:487:50: error: use of undeclared identifier 'my_bool_true'
        if (mysql_options(&mysql, MYSQL_OPT_RECONNECT, &my_bool_true) != 0) {
                                                        ^
2 errors generated.
gmake[3]: *** [/usr/ports/net/asterisk16/work/asterisk-16.11.1/Makefile.rules:164: cdr_mysql.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[3]: Leaving directory '/usr/ports/net/asterisk16/work/asterisk-16.11.1/addons'
gmake[2]: *** [Makefile:387: addons] Error 2
gmake[2]: Leaving directory '/usr/ports/net/asterisk16/work/asterisk-16.11.1'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/net/asterisk16
*** Error code 1

Stop.
```


----------



## T-Daemon (Jun 18, 2020)

Try building without MySQL support. Might be a regression, version 16.11.0 builds fine for pkg repository:



			http://beefy6.nyi.freebsd.org/data/121amd64-default/539306/logs/asterisk16-16.11.0.log
		


Note: Don't follow every none FreeBSD related example installation guide. The idea to pull the asterisk17 source code under /usr/src (with git perhaps?) originated from their wiki, isn't it?


----------



## for.ggame.playing (Jun 18, 2020)

I do not use pkg repository as I can not configure it to work with mysql!/ so What am I supposed to do if I disable support for mysql?? How am I supposed to integrate it with mysql? If you have any ideas please inform me about that.
My bad! I was supposed to install it on /usr/local/src/ folder as it was stated on FREEBSD 10.1 installation guide. I wrongly supposed it to be moved to /usr/src(because the folder /usr/local/src does not existed) and than I got that error. 
Than I found out that there is a port repository by chance and I find it convinient to download from there.


----------



## SirDice (Jun 19, 2020)

for.ggame.playing said:


> I do not use pkg repository as I can not configure it to work with mysql!


It's  on  by default:

```
MYSQL=on: MySQL database support
```
Which means the package has the option turned on.


----------



## T-Daemon (Jun 19, 2020)

for.ggame.playing said:


> I do not use pkg repository as I can not configure it to work with mysql!/


I haven't suggested to use a pkg repository. With the build log of version 16.11.0 for the official package repository I pointed out there is no problem in building the port with the default configuration, in which MySQL is enabled (MYSQL=on).

You showed in you posting (#3) a build error for net/asterisk16 (version 16.11.1), involving a MySQL option, returning an error. Doesn't it make sense to debug the build error by excluding MySQL support, then retry the build? I'm not talking about to obtain a package for use, but for narrowing down the problem. If the build ends successful you have found the source (or other errors may surface), then you can file a bug report, in case no one else from the forum presents a solution. Or you can file a bug report immediately.

There is an open bug report, PR 246764, for an older version, but not for the latest port.

I considered to run a test build for the port, but for that I need to install 197 missing dependencies. Sorry, but I wont go that far to investigate the problem, you need do it yourself, but we can assist with suggestions.



for.ggame.playing said:


> I was supposed to install it on /usr/local/src/


You don't have to install it in /usr/local/src, the home directory of any user will do.



for.ggame.playing said:


> ... and than I got that error.


I doubt you will find support here for a directly from source code build, not port. Also there are to consider the dependencies for asterisk. For the port there are 294 run and build dependencies, matched carefully to be integrated into the system. If build directly from source you are responsible to assure the right run/build dependencies, integration and maintenance. If you insist on version 17 from source code you could try asking at the asterisk forum: https://community.asterisk.org/.

Don't take it as we are scolding you, and don't mind the pungent expressed replies. Most of us are willing to help if possible.


----------



## T-Daemon (Jun 19, 2020)

net/asterisk16 has been updated to version 16.11.1_1. Try that one.


----------



## T-Daemon (Jun 21, 2020)

net/asterisk16 (16.11.1_1) builds fine with the default data base configuration:

```
====> Database Support
     MYSQL=on: MySQL database support
     ODBC=on: ODBC database backend
     PGSQL=on: PostgreSQL database support
     SQLITE2=on: SQLite 2 database support
```



			http://beefy6.nyi.freebsd.org/data/121amd64-default/539685/logs/asterisk16-16.11.1_1.log
		


In case you are using another version of MySQL than the default of 5.7:

/usr/ports/Mk/bsd.default-versions.mk

```
# Possible values: 5.5, 5.6, 5.7, 8.0, 5.5m, 10.1m, 10.2m, 10.3m, 10.4m, 5.5p, 5.6p, 5.7p, 5.6w
MYSQL_DEFAULT?=         5.7
```

set in /etc/make.conf eg.:

```
DEFAULT_VERSIONS+= mysql=8.0
```


----------



## Yandri Loor (Nov 29, 2020)

for.ggame.playing said:


> I wanted to install asterisk on my FreeBSD 12.1-Release PC from asterisk source code.
> I managed to install packages on /usr/src directory, however make command outputs error
> 
> ```
> ...


Have you already fixed that error?


----------



## SirDice (Nov 30, 2020)

Use the port/package.


----------

