Example program not compiling while using it in C++


Postby arayappan » Tue May 21, 2013 6:51 am

Hi All,

I tried to compile example/main.c in C++ environement using the following compiling statements but it is throwing errors. I just renamed main.c to main.cc

When i compile it in C environment, it is compiling and linking successfully without any errors.

For compiling(no errors, successful copiling):

g++ -g -std=c++0x -Wall -D_REENTRANT -D MARCH_x86_64 -MMD -o aerospike/obj/main.o -c -I./aerospike/include -I…/…/cf_base/include main.cc

For linking(throws error):

g++ -g -std=c++0x -Wall -D_REENTRANT -D MARCH_x86_64 -L./aerospike/lib -o ./cl_example aerospike/obj/main.o -lcitrusleaf -lssl -lpthread -lrt -lcrypto -lz aerospike/obj/main.o: In function main': /home/ubuntu/rtbkit/examples/main.cc:264: undefined reference tocitrusleaf_use_shm(int, int)' collect2: ld returned 1 exit status

Please anyone explain me what is wrong in my compilation statement.

Regards, Rayappan A


Postby arayappan » Tue May 21, 2013 7:51 pm


I fixed this issue.

It was my mistake. I forgot to include extern “C” {} in include section of header files.

Thanks, Rayappan A


Postby young » Wed May 22, 2013 5:46 pm

No problem. Glad you fixed it before we could even reply.