kino-chen
kino-chen

Reputation: 40

"undefined reference" even the lib has a symbol of the function

When i linked the .o files,some problems happened:

gcc -L/usr/local/apr/lib -lapr-1 -pthread -laprutil-1  devpkg.o bstrlib.o db.o shell.o commands.o   -o devpkg
devpkg.o: In function `main':
/root/workspace/devpkg/devpkg.c:21: undefined reference to `apr_pool_initialize'
/root/workspace/devpkg/devpkg.c:22: undefined reference to `apr_pool_create_ex'
/root/workspace/devpkg/devpkg.c:36: undefined reference to `apr_getopt_init'
/root/workspace/devpkg/devpkg.c:38: undefined reference to `apr_getopt'

I used "objdump -T" to check the lib,it returned:

objdump -T libapr-1.so|grep apr_pool_initialize
000000000001db00 g    DF .text  00000000000000fb  Base        apr_pool_initialize

Why did this happen?

Upvotes: 0

Views: 821

Answers (1)

downhillFromHere
downhillFromHere

Reputation: 1977

This is most likely just a simple dependency issue. You might want to try listing all the libraries you link to after the .o files, in the right order based on their dependencies with one another.

Upvotes: 2

Related Questions