# Compiling openldap24-server with ODBC checked fails with linker error -liodbc



## ro (Nov 13, 2014)

Hi,

FreeBSD 10.0, amd64, clang, PKGNG. No additional compile flags in /etc/make.conf present. I have an issue with compiling openldap24-server

```
OPTIONS_FILE_SET+=ODBC
```


```
...
/bin/sh ../../../libtool --tag=disable-static --mode=compile  cc -O2 -pipe -DMDB_DSYNC=O_SYNC -Dfdatasync=fsync -fstack-protector -DLDAP_DEPRECATED -fno-strict-aliasing -I../../../include -I../../../include -I.. -I./..  -I/usr/local/include  -DSLAPD_IMPORT -c api.c
cc -O2 -pipe -DMDB_DSYNC=O_SYNC -Dfdatasync=fsync -fstack-protector -DLDAP_DEPRECATED -fno-strict-aliasing -I../../../include -I../../../include -I.. -I./.. -I/usr/local/include -DSLAPD_IMPORT -c api.c  -fPIC -DPIC -o .libs/api.o
rm -f version.c
../../../build/mkversion -v "2.4.40" back_sql > version.c
/bin/sh ../../../libtool --tag=disable-static --mode=compile  cc -O2 -pipe -DMDB_DSYNC=O_SYNC -Dfdatasync=fsync -fstack-protector -DLDAP_DEPRECATED -fno-strict-aliasing -I../../../include -I../../../include -I.. -I./..  -I/usr/local/include  -DSLAPD_IMPORT -c version.c
cc -O2 -pipe -DMDB_DSYNC=O_SYNC -Dfdatasync=fsync -fstack-protector -DLDAP_DEPRECATED -fno-strict-aliasing -I../../../include -I../../../include -I.. -I./.. -I/usr/local/include -DSLAPD_IMPORT -c version.c  -fPIC -DPIC -o .libs/version.o
/bin/sh ../../../libtool --tag=disable-static --mode=link  cc -O2 -pipe -DMDB_DSYNC=O_SYNC -Dfdatasync=fsync -fstack-protector -DLDAP_DEPRECATED -fno-strict-aliasing  -Wl,-rpath,/usr/lib:/usr/local/lib -fstack-protector  -release 2.4 -version-info 12:3:10 -rpath /usr/local/libexec/openldap -module -o back_sql.la init.lo config.lo search.lo bind.lo compare.lo operational.lo  entry-id.lo schema-map.lo sql-wrap.lo modify.lo util.lo  add.lo delete.lo modrdn.lo api.lo version.lo  ../../../libraries/libldap_r/libldap_r.la ../../../libraries/liblber/liblber.la -liodbc
cc -shared  .libs/init.o .libs/config.o .libs/search.o .libs/bind.o .libs/compare.o .libs/operational.o .libs/entry-id.o .libs/schema-map.o .libs/sql-wrap.o .libs/modify.o .libs/util.o .libs/add.o .libs/delete.o .libs/modrdn.o .libs/api.o .libs/version.o  -Wl,--rpath -Wl,/usr/ports/net/openldap24-server/work/openldap-2.4.40/libraries/libldap_r/.libs -Wl,--rpath -Wl,/usr/ports/net/openldap24-server/work/openldap-2.4.40/libraries/liblber/.libs -Wl,--rpath -Wl,/usr/local/lib ../../../libraries/libldap_r/.libs/libldap_r.so ../../../libraries/liblber/.libs/liblber.so -liodbc  -Wl,-rpath -Wl,/usr/lib:/usr/local/lib -Wl,-soname -Wl,back_sql-2.4.so.2 -o .libs/back_sql-2.4.so.2.10.3
/usr/bin/ld: cannot find -liodbc
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [back_sql.la] Error code 1

make[5]: stopped in /usr/ports/net/openldap24-server/work/openldap-2.4.40/servers/slapd/back-sql
1 error
...
```

Some additional information:

```
# pkg info "*odbc*"
libiodbc-3.52.9
postgresql-odbc-09.01.0200_1
# pkg info "*ODBC*"
unixODBC-2.3.2_1
```
iodbc.so is part of libiodbc-*

```
# iodbc-config --libs
-L/usr/local/lib  -liodbc -liodbcinst

# ls  /usr/local/lib | grep iodbc
libiodbc.a
libiodbc.so
libiodbc.so.2
libiodbc.so.2.1.20
libiodbcinst.a
libiodbcinst.so
libiodbcinst.so.2
libiodbcinst.so.2.1.20
```
Oooops, iodbc* not presents. I've tried to fix it:

```
cp libiodbc.a iodbc.a; cp libiodbc.so.2.1.20 iodbc.so.2.1.20; ln -s iodbc.so.2.1.20 iodbc.so; ln -s iodbc.so.2.1.20 iodbc.so.2; ldconfig -R
# ls -lah /usr/local/lib | grep iodbc
-rw-r--r--  1 root  wheel  675K Nov 13 01:06 iodbc.a
lrwxr-xr-x  1 root  wheel  15B Nov 13 01:11 iodbc.so -> iodbc.so.2.1.20
lrwxr-xr-x  1 root  wheel  15B Nov 13 01:11 iodbc.so.2 -> iodbc.so.2.1.20
-rwxr-xr-x  1 root  wheel  333K Nov 13 01:07 iodbc.so.2.1.20
-rw-r--r--  1 root  wheel  675K Nov 13 00:43 libiodbc.a
lrwxr-xr-x  1 root  wheel  18B Nov 13 00:43 libiodbc.so -> libiodbc.so.2.1.20
lrwxr-xr-x  1 root  wheel  18B Nov 13 00:43 libiodbc.so.2 -> libiodbc.so.2.1.20
-rwxr-xr-x  1 root  wheel  333K Nov 13 00:43 libiodbc.so.2.1.20
-rw-r--r--  1 root  wheel  159K Nov 13 00:43 libiodbcinst.a
lrwxr-xr-x  1 root  wheel  22B Nov 13 00:43 libiodbcinst.so -> libiodbcinst.so.2.1.20
lrwxr-xr-x  1 root  wheel  22B Nov 13 00:43 libiodbcinst.so.2 -> libiodbcinst.so.2.1.20
-rwxr-xr-x  1 root  wheel  69K Nov 13 00:43 libiodbcinst.so.2.1.20
```
But it has no any effect. Same linker error like 
	
	



```
/usr/bin/ld: cannot find -liodbc
```
 during compilation. Can anybody help me to resolve this issue?


----------



## talsamon (Nov 13, 2014)

Compiles on my machine with `make install clean CC=gcc48 CXX=c++48  CPP=cpp48` with all options on (except experimental, deprecated options) and except SASL and GSSAPI.


----------



## ro (Nov 14, 2014)

I've fixed the issue by running the last command and replacing -liodbc to /usr/local/lib/libiodbc.so. But it is not good. I'll make it every time, when openldap24-server needs an update.


----------

