6

我想使用 GNU Autotools 构建一个使用 ZipArchive 的共享库,但我遇到了这个问题:

警告:链接器路径没有库 -lziparch 的真实文件。
我有能力使该库在何时自动链接
你链接到这个库。但我只能在你有一个
库的共享版本,您似乎没有
因为我确实检查了链接器路径以查找文件开始
使用 libziparch 并且没有候选人通过文件格式测试
使用文件魔术。最后检查的文件:/usr/local/ZipArchive/ZipArchive/libziparch.a
此处已删除的库间依赖项将是
每当程序与此库链接时自动添加
或被声明为 -dlopen 它。

如果我构建一个静态库或者如果我使用 ZipArchive 的共享库,它可以工作,但问题是 ZipArchive 源代码附带的 makefile 只构建一个静态库。

如何强制 Libtool 与静态库链接?

4

1 回答 1

5

Generally, static archives are created with non-pic object files and they cannot be put into shared libraries.

What this message is telling you though, is that when a program links to YOUR library using Libtool, that -lziparch will get added to the link. So you don't need to change anything unless you're building a module for an interpreted language. In that case, you will have to build ZipArchive as a shared library. In addition, this wouldn't work on a platform like MS Windows where shared libraries (DLLs) have to resolve all their symbols at link time.

All that said, if your ziparch static lib is PIC code, you can use the -whole-archive flag when linking it to your library. This would be the least portable solution though.

于 2012-10-17T16:39:29.477 回答