Linking issues on ubuntu 14.04


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, 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++ -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 doesn’t have dependencies on these libraries?

#> ldd /usr/lib/ (0x00007fff0c9ff000) => /lib/x86_64-linux-gnu/ (0x00007f216bf89000)
	/lib64/ (0x00007f216c5ca000)


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.

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


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 -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:( 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 ofTMC_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 !!!


gcc -DAS_USE_LIBEV -fPIC -c -o aerospikeWriteOperation.o aerospikeWriteOperation.c gcc -shared -o aerospikeWriteOperation.o


Thanks a lot Brain.