# Erlang Client Not Loading NIF

**URL:** <https://discuss.aerospike.com/t/erlang-client-not-loading-nif/3380>\
**Category:** Erlang Client\
**Created:** [September 10, 2016, 3:36pm UTC](https://discuss.aerospike.com/t/erlang-client-not-loading-nif/3380 "2016-09-10T15:36:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keam](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@Keam](https://discuss.aerospike.com/u/Keam)\
**Post date:** [September 10, 2016, 3:36pm UTC](https://discuss.aerospike.com/t/erlang-client-not-loading-nif/3380/1 "2016-09-10T15:36:19Z")

</div>

Hi,

Saw this issue posted on a few dated threads…has this been solved? I’m running into the same issue. followed all direction setting Makefile to proper version of Erlang (3.8.2). Currently, I’m running Ubuntu Server (16.04). I’ve apt-get installed the openssl libs. Everything works fine. But when I do the following to test the nif.so file i get the following message:

```
  1> erlang:load_nif("./aerospike_nif", 0).
        {error,{load_failed,"Failed to load NIF library: './aerospike_nif.so: undefined symbol: RIPEMD160_Init'"}}

```

I also added the -lcrypto link in the Makefile. Everything compiled nicely no problems but still get the error above.

Any suggestions would be greatly appreciated.

Thank you

---

<div class="post-metadata">

**Author:** ![Keam](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@Keam](https://discuss.aerospike.com/u/Keam)\
**Post date:** [September 10, 2016, 9:35pm UTC](https://discuss.aerospike.com/t/erlang-client-not-loading-nif/3380/2 "2016-09-10T21:35:59Z")

</div>

So I did a little digging around…and did the following

```
$ cd /aerospike-client-erlang-2.1.2/
$ grep -Hrl 'RIPEMD160_Init' ./c
$ ./citrusleaf/cf_digest.h
$ cd /c/include/citrusleaf/
$ vim cf_digest.h

/*
 * Citrusleaf Foundation
 * include/digest.h - message digests
 *
 * Copyright 2008 by Citrusleaf. All rights reserved.
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE. THE COPYRIGHT NOTICE
 * ABOVE DOES NOT EVIDENCE ANY ACTUAL OR INTENDED PUBLICATION.
 */

#pragma once

#include <stddef.h>
#include <stdint.h>
#include <openssl/ripemd.h>

/* SYNOPSIS
 * Cryptographic message digests
 * The intent is to provide an algorithm-neutral API for the computation of
 * cryptographic digests of arbitrary bytes. Consequently, we define the
 * cf_digest type to be an array of bytes of the appropriate length.
 * The actual computation is done in one shot by calling cf_digest_compute().
 */

#ifdef __cplusplus
extern "C" {
#endif

/* cf_digest
 * Storage for a message digest */
#define CF_DIGEST_KEY_SZ RIPEMD160_DIGEST_LENGTH
typedef struct { uint8_t digest[CF_DIGEST_KEY_SZ]; } cf_digest;

void cf_digest_string(cf_digest *digest, char* output);
void cf_digest_dump(cf_digest *digest);

/* cf_digest_compute
* Compute the digest of an input */
static inline void
cf_digest_compute(void *data, size_t len, cf_digest *d)
{
        RIPEMD160((const unsigned char *) data, len, (unsigned char *) d->digest);
}

// Compute a digest
// the first value is the key data, the second is the set
// DO NOT USE THIS FUNCTION EXTERNALLY
// the externally visible function is 'citrusleaf_calculate_digest', which has
// the proper typing and swizzling

static inline void
cf_digest_compute2(void *data1, size_t len1, void *data2, size_t len2, cf_digest *d)
{
        if (len1 == 0) {
                RIPEMD160((const unsigned char *) data2, len2, (unsigned char *) d->digest);
        }
        else {
                RIPEMD160_CTX c;
                RIPEMD160_Init(&c);
                RIPEMD160_Update(&c, data1, len1);
                RIPEMD160_Update(&c, data2, len2);
                RIPEMD160_Final( (unsigned char *)(d->digest), &c);
        }
}

/* as_partition_getid
 * A brief utility function to derive the partition ID from a digest */

typedef uint16_t cl_partition_id;
static inline cl_partition_id
cl_partition_getid(uint32_t n_partitions, const cf_digest *d)

```

its this part that stood out to me…

```
static inline void
cf_digest_compute2(void *data1, size_t len1, void *data2, size_t len2, cf_digest *d)
{
        if (len1 == 0) {
                RIPEMD160((const unsigned char *) data2, len2, (unsigned char *) d->digest);
        }
        else {
                RIPEMD160_CTX c;
                RIPEMD160_Init(&c);
                RIPEMD160_Update(&c, data1, len1);
                RIPEMD160_Update(&c, data2, len2);
                RIPEMD160_Final( (unsigned char *)(d->digest), &c);
        }
}

```

According to [openssl.org](https://www.openssl.org/docs/man1.0.2/crypto/RIPEMD160_Init.html)

> The following functions may be used if the message is not completely stored in memory:

> RIPEMD160\_Init() initializes a RIPEMD160\_CTX structure.

> RIPEMD160\_Update() can be called repeatedly with chunks of the message to be hashed (len bytes at data).

> RIPEMD160\_Final() places the message digest in md, which must have space for RIPEMD160\_DIGEST\_LENGTH == 20 bytes of output, and erases the RIPEMD160\_CTX.

> Applications should use the higher level functions EVP\_DigestInit etc. instead of calling the hash functions directly.

From what I can tell it is directly calling the hash functions `RIPEMD160_Init` instead of using [EVP\_DigestInit](https://www.openssl.org/docs/man1.0.2/crypto/EVP_DigestInit.html) as recommended. Also on [openssl.org](https://www.openssl.org/docs/man1.0.2/crypto/RIPEMD160_Init.html)`RIPEMD160_Init` is defined as type `int` but the code doesn’t explicitly define type `int`. I don’t know if this is also causing the problem.

I don’t know C all that well. But I hope this can provide some clues about the cause of the problem. I really wanna start using Aerospike in my dev setup.

Any guidance will be appreciated…

---

<div class="post-metadata">

**Author:** ![wchu](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@wchu](https://discuss.aerospike.com/u/wchu)\
**Post date:** [September 12, 2016, 11:00am UTC](https://discuss.aerospike.com/t/erlang-client-not-loading-nif/3380/3 "2016-09-12T11:00:50Z")

</div>

The same functionality is used in the aerospike\_client\_c, which supports all ubuntu platforms. Most likely this is still some library path resolution or version issue with the Erlang installation.

Incidentally, the Aerospike Erlang client is not actively worked on due to the limited number of users, and thus missing many of the new features that Aerospike server has developed (such as secondary indexing, geo query, list/maps)

See [http://www.aerospike.com/docs/guide/client\_matrix.html](http://www.aerospike.com/docs/guide/client_matrix.html) for most up-to-date functionality support.

---

<div class="post-metadata">

**Author:** ![Keam](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@Keam](https://discuss.aerospike.com/u/Keam)\
**Post date:** [September 12, 2016, 3:42pm UTC](https://discuss.aerospike.com/t/erlang-client-not-loading-nif/3380/4 "2016-09-12T15:42:32Z")

</div>

Thank you,

Are you suggesting I try the aerospike\_client\_c for my Ubuntu 16.04 install?

And yes, I can already see there isn’t that much support for it… Riak\_TS might be a better option.

---

<div class="post-metadata">

**Author:** ![bbulkow](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bbulkow](https://discuss.aerospike.com/u/bbulkow)\
**Post date:** [October 30, 2017, 8:43pm UTC](https://discuss.aerospike.com/t/erlang-client-not-loading-nif/3380/5 "2017-10-30T20:43:43Z")

</div>

Not much support for Riak these days either.

If someone who knows Erlang better ( great tip about EVP\_DigestInit ) would love to dive in, we’re happy to help along getting Erlang into a proper community support role.
