hi i have a .so file written in c and i am trying to use it in a c++ program but when i try to compile the c++ code it gives me undefined reference to function getNearestAP() which is a part of my .so file.To add to this i tried with a c program to use the .so file surprisingly i was able to compile it and successfully execute it.Any help would be very much appreciated.

I think you want the -l flag of g++.

no sir i have given the all the flags which i used for my c program but with c++ it did not work

Can you show us both the working c command and the non-working c++ command?

for c code

gcc -o connect.c `pkg-config --cflags connectivity --libs connectivity`

for c++

gcc -o connect.cpp `pkg-config --cflags connectivity --libs connectivity`


connectivity is my .so name i have created a .pc file for it .
my PKG_CONFIG_PATH variable is also set

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.