[Xapian-discuss] undefined reference to "function name"

Zhiguo Li zhiguo.li at gmail.com
Sat Nov 29 18:49:55 GMT 2008


Hightman(马明练) wrote:
> If you call some function from C library (not C++), you should do it such as:
> extern "C" {
>  #include "something.h";
>  ...
> }
>
>   
Hi,

Thanks for your suggestion. I tried it but it didn't work and I don't
think it's the name mangling problem.

Though the following hack works:

change:
g++ -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align
-Wno-long-long -Wformat-security -Wconversion -fno-gnu-keywords -Wundef
-Wshadow -Winit-self -Wstrict-overflow=5 -fvisibility=hidden -g -O2 -o
examples/.libs/simplesearch examples/simplesearch.o ./.libs/libxapian.so -lz


to:
g++ -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align
-Wno-long-long -Wformat-security -Wconversion -fno-gnu-keywords -Wundef
-Wshadow -Winit-self -Wstrict-overflow=5 -fvisibility=hidden -g -O2 -o
examples/.libs/simplesearch examples/simplesearch.o matcher/something.o
./.libs/libxapian.so -lz

I just added matcher/something.o object to the linker.

I am still not sure why. Maybe the link order? Since symbol "something"
lies in both proximity.o and libxapian.so, and why cannot the linker
find it?

I may live with the hack right now.

Thanks,
Kevin




More information about the Xapian-discuss mailing list