A
A
Artyom2013-03-21 19:50:16
linux
Artyom, 2013-03-21 19:50:16

Undefined symbol when loading a library via dlopen?

I'm trying to write a plugin for one program that would add support for Redis. It needs to write several functions that will be called. I use github.com/redis/hiredis for this.
If you just build hiredis, then everything works fine. If I collect so, then when I try to load through dlopen, I get an error undefined symbol: redisConnectWithTimeout.
The problem is most likely in how I compile this case: it gcc -I./ -fPIC -shared example.c -o plugin.so
nm plugin.soshows the following:

U redisConnectWithTimeout
U redisFree

I also tried installing hiredis and compiling with -lhiredis, same result.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
theaspin, 2013-03-21
@theaspin

Try adding the -rdynamic flag when compiling the plugin. With what flags is dlopen called?

T
theaspin, 2013-03-21
@theaspin

It is also worth adding -ldl when compiling.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question