Undefined reference to `as_key_init_strp'


#1

Hi,

I have written a small C program that uses the C client library (Ubuntu 16.04 - latest client version as of this date) to connect to Aerospike.

I am using the following command to compile:

g++ -o dim.out -L/usr/lib/ -laerospike -I/usr/include/ dimension_reader.cpp main.cpp

I get this error during compilation:

/tmp/cchIjT7W.o: In function `as_key_init_str':
dimension_reader.cpp:(.text+0x1f54): undefined reference to `as_key_init_strp'
/tmp/cchIjT7W.o: In function `DimensionReader::DimensionReader(char const*, int)':
dimension_reader.cpp:(.text+0x1f75): undefined reference to `as_config_init'
dimension_reader.cpp:(.text+0x1f8e): undefined reference to `as_config_add_host'
dimension_reader.cpp:(.text+0x1fa8): undefined reference to `aerospike_init'
dimension_reader.cpp:(.text+0x1fc8): undefined reference to `aerospike_connect'

I have all the libraries and header files on my system. Any idea what could be the cause of this?

Any help much appreciated.

Thanks! Aashish


#2

C++ programs are supported in Ubuntu 16.04. Please provide source code that does not compile.


#3

Hi Brian,

Please find below my source code which is not getting compiled using gcc and providing error message as :

"test.c:(.text+0x1e1b): undefined reference to `as_config_init'
collect2: error: ld returned 1 exit status"
"#include stdio.h"
"#include stdlib.h"
"#include aerospike/aerospike_batch.h"
"#include aerospike/aerospike.h"
"#include aerospike/as_config.h"
"#include aerospike/as_error.h"
int main()
{
        as_error err;
        as_config config;

        as_config_init(&config);

        printf("End of Program! Success!\n");

return(0);
}

#4

This seems a basic programming and linking issue not related to Aerospike.

I would recommend going back to the basics, by start looking at the ample number of example programs provided in the package.