1

So I am trying to statically link Xerces 3.0.0 on linux.

I did it already with dynamic link and it works, but in order to avoid dependancy I want to do it statically.

I changed all of the make files to do it in appropriate way

-Wl,-Bstatic ... -lxerces-c -Wl,-Bdynamic ...

But I am getting following errors:

  undefined reference to '__ctype_b'
  undefined reference to '__ctype_tolower'
  undefined reference to '__ctype_toupper'

I fixed those with brute force method found here

But there was another type of errors related to xerces.

Xerces/3.0.0/lib/libxerces-c.a(PosixMutexMgr.o): 
In function `xercesc_3_0::PosixMutexMgr::create(xercesc_3_0::MemoryManager*)':

PosixMutexMgr.cpp:(.text+0x84): undefined reference to `pthread_mutexattr_init'
PosixMutexMgr.cpp:(.text+0x95): undefined reference to `pthread_mutexattr_settype'
PosixMutexMgr.cpp:(.text+0xad): undefined reference to `pthread_mutexattr_destroy'
PosixMutexMgr.cpp:(.text+0xd0): undefined reference to `pthread_mutexattr_destroy'

It seems like its missing pthread so I tried adding it but that does not fix the problem... These errors are coming from Xerces ...and dynamic version works fine static one is failing.

Any ideas???

Thanks

grobartn
  • 3,510
  • 11
  • 40
  • 52

2 Answers2

1

The dynamic version of the xerces will have dependencies on libpthread that ensure the loader will pick up the correct library.

Specifying libphtread on your linker command line should fix those unresolved externals, did you (a) put in in the right place on the command line as the ordering matters and (b) did you try the both the static and dynamic versions of libpthread?

Timo Geusch
  • 24,095
  • 5
  • 52
  • 70
  • I did not try the dynamic version of pthread lib. But I will try that too – grobartn Dec 01 '10 at 18:14
  • Did you add -lpthread before or after -lxerces-c? IIRC it needs to go *after*, if you put it before then the ordering is wrong and you'll still get the unresolved symbols. – Timo Geusch Dec 01 '10 at 18:19
  • it was after but dynamic version of pthread works so i will mark this as answer.. thanks – grobartn Dec 02 '10 at 21:44
0

The order of the lib linked matters for the linker, try changing the order for pthread lib.

Rajivji
  • 305
  • 1
  • 2