2012-06-26 98 views
5

我想建立使用ZipArchive GNU Autotools的,但我有這個問題,它使用的共享庫:如果我建一個靜態庫,或者如果我使用ZipArchive的共享庫,它的工作原理,但問題爲什麼Libtool不想鏈接靜態庫?

Warning: linker path does not have real file for library -lziparch. 
I have the capability to make that library automatically link in when 
you link to this library. But I can only do this if you have a 
shared version of the library, which you do not appear to have 
because I did check the linker path looking for a file starting 
with libziparch and none of the candidates passed a file format test 
using a file magic. Last file checked: /usr/local/ZipArchive/ZipArchive/libziparch.a 
The inter-library dependencies that have been dropped here will be 
automatically added whenever a program is linked with this library 
or is declared to -dlopen it.

是ZipArchive源代碼附帶的makefile只生成一個靜態庫。

如何強制Libtool鏈接靜態庫?

回答

4

通常情況下,靜態存檔是使用非pic對象文件創建的,它們不能放入共享庫。

這條消息告訴你的是,當一個程序使用Libtool鏈接到你的庫時,-lziparch將被添加到鏈接中。所以你不需要需要來改變任何東西,除非你正在構建一個解釋型語言的模塊。在這種情況下,您將不得不將ZipArchive構建爲共享庫。另外,這不適用於MS Windows這樣的平臺,因爲共享庫(DLL)必須在鏈接時解析所有的符號。所有這些,如果你的ziparch靜態庫是PIC代碼,你可以在將它鏈接到你的庫時使用-whole-archive標誌。儘管如此,這將是最不便攜的解決方案。