Example program(main.c) not in C++ environment


#1

Hi All,

I tried to compile examples/main.c program in C++ environment but it is throwing errors in link section.

i just renamed main.c to main.cc for compiling in c++ environment.

In C environment, it is compiling and linking successfully and working fine.

for compiling(no errors, successfully compiling)

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(Errors):

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 with my compilation statement.

Regards, Rayappan A


#2

Hi,

I fixed this issue.

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

Thanks Rayappan A