1

所以我试图在linux上静态链接Xerces 3.0.0。

我已经用动态链接做了它并且它有效,但为了避免依赖我想静态地做它。

我更改了所有的制作文件以适当的方式进行

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

但我收到以下错误:

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

我用这里找到的蛮力方法修复了那些

但是还有另一种与 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'

它似乎缺少pthread,所以我尝试添加它,但这并不能解决问题......这些错误来自Xerces......并且动态版本工作正常静态一个失败。

有任何想法吗???

谢谢

4

2 回答 2

1

xerces 的动态版本将依赖于 libpthread,以确保加载器将选择正确的库。

在链接器命令行上指定 libphtread 应该可以修复那些未解决的外部问题,您是否 (a) 在命令行中放置了正确的位置,因为排序很重要,并且 (b) 您是否尝试了 libpthread 的静态和动态版本?

于 2010-12-01T18:11:53.723 回答
0

lib 链接的顺序对链接器很重要,请尝试更改 pthread lib 的顺序。

于 2010-12-01T18:11:46.937 回答