# Linking issues on ubuntu 14.04

**URL:** <https://discuss.aerospike.com/t/linking-issues-on-ubuntu-14-04/2395>\
**Category:** C Client Library\
**Created:** [January 15, 2016, 2:48pm UTC](https://discuss.aerospike.com/t/linking-issues-on-ubuntu-14-04/2395 "2016-01-15T14:48:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![manana](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@manana](https://discuss.aerospike.com/u/manana)\
**Post date:** [January 15, 2016, 2:48pm UTC](https://discuss.aerospike.com/t/linking-issues-on-ubuntu-14-04/2395/1 "2016-01-15T14:48:06Z")

</div>

I run into linking issues using libaerospike on ubuntu 14.04. Here is sample program, that does nothing:

```
#include <aerospike/as_double.h>

int main() {
    as_double x;
    as_double_init(&x, 1);                                                                                                                                                 
}

```

When I use ld flags suggested [here](https://discuss.aerospike.com/t/libaerospike-so-undefined-symbol-rand-seed/1023/2), I have to add -lz, but still I have success only with g+±4.4. Newer version (tested 4.7, 4.8, 4.9) always ends with undefined symbols from lm, lcrypto, ldl. The command is ` g++ a.cc -laerospike -lssl -lcrypto -lpthread -lrt -ldl -lz`. I don’t have this problems on debian 7.1 nor debian 8.2.

I’m curious why libaerospike.so doesn’t have dependencies on these libraries?

```
#> ldd /usr/lib/libaerospike.so
	linux-vdso.so.1 (0x00007fff0c9ff000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f216bf89000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f216c5ca000)

```

---

<div class="post-metadata">

**Author:** ![Brian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/brian/32/2211_2.png) [@Brian](https://discuss.aerospike.com/u/Brian)\
**Post date:** [February 4, 2016, 7:33pm UTC](https://discuss.aerospike.com/t/linking-issues-on-ubuntu-14-04/2395/2 "2016-02-04T19:33:17Z")

</div>

I was able to duplicate the error with your link line with gcc 4.8.2. You need to put the crypto library before the ssl library. Also, the math library is needed “-lm”. The following compile/link steps work for me on ubuntu 14.04 with gcc 4.8.2.

```bash
gcc -o a.o -c a.c
gcc -o a a.o -laerospike -lcrypto -lssl -lpthread -lm -lrt -ldl -lz

```

---

<div class="post-metadata">

**Author:** ![b.sangole](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@b.sangole](https://discuss.aerospike.com/u/b.sangole)\
**Post date:** [May 23, 2017, 11:49am UTC](https://discuss.aerospike.com/t/linking-issues-on-ubuntu-14-04/2395/3 "2017-05-23T11:49:04Z")

</div>

Hi Brian, I am also having issue with linking libraries of aerospike while creating shared object file from object file of c program.

```
For creating object file I am using following command : gcc -DAS_USE_LIBEV -o aerospikeWriteOperation.o aerospikeWriteOperation.c -laerospike -lssl -lcrypto -lpthread -lm -lz

```

Above command is able to create the object file. but when I am trying create shared object file using following command, .so file is not getting generated. Can you please help me with this issue :

gcc aerospikeWriteOperation.o -shared -DAS\_USE\_LIBEV -o aerospikeWriteOperation.so -laerospike -lssl -lcrypto -lpthread -lm -lz

Error: aerospikeWriteOperation.o:(.rodata+0x8): multiple definition of `__dso_handle' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbeginS.o:(.data.rel.ro+0x0): first defined here aerospikeWriteOperation.o: In function `\_fini’: (.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o:(.fini+0x0): first defined here aerospikeWriteOperation.o: In function `\_init’: (.init+0x0): multiple definition of `_init' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o:(.init+0x0): first defined here /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtendS.o:(.tm_clone_table+0x0): multiple definition of ` **TMC\_END** ’ aerospikeWriteOperation.o:(.data+0x8): first defined here /usr/bin/ld: warning: Cannot create .eh\_frame\_hdr section, --eh-frame-hdr ignored. /usr/bin/ld: error in aerospikeWriteOperation.o(.eh\_frame); no .eh\_frame\_hdr table will be created. collect2: error: ld returned 1 exit status

Thank you !!!

---

<div class="post-metadata">

**Author:** ![Brian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/brian/32/2211_2.png) [@Brian](https://discuss.aerospike.com/u/Brian)\
**Post date:** [May 23, 2017, 11:58pm UTC](https://discuss.aerospike.com/t/linking-issues-on-ubuntu-14-04/2395/4 "2017-05-23T23:58:05Z")

</div>

gcc -DAS\_USE\_LIBEV -fPIC -c -o aerospikeWriteOperation.o aerospikeWriteOperation.c gcc -shared -o aerospikeWriteOperation.so aerospikeWriteOperation.o

---

<div class="post-metadata">

**Author:** ![b.sangole](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@b.sangole](https://discuss.aerospike.com/u/b.sangole)\
**Post date:** [May 24, 2017, 4:27am UTC](https://discuss.aerospike.com/t/linking-issues-on-ubuntu-14-04/2395/5 "2017-05-24T04:27:17Z")

</div>

> [@Brian](#):
>
> gcc -shared -o aerospikeWriteOperation.so aerospikeWriteOperation.

Thanks a lot Brain.
