Statically linking a library on Linux

时间:2022-09-18 12:26:07

I'm trying to make an XPCOM component for Firefox 3.6.*. It uses libsqlite3 version 3.7.4 compiled statically (with program independent code generation -- -fPIC compiler option). The problem I'm facing is that once Firefox loads the component and it starts executing, the sqlite3_libversion_number() returns 3007001 while the macro SQLITE_LIBVERSION_NUMBER is defined to 3007004. I'm pretty sure that I'm linking against the correct static sqlite3 library... But how can I double check this? ldd output of the generated shared object doesn't list libsqlite3.so as a dependency (although libxul.so, used for creating the XPCOM component, uses libsqlite3.so). How are all sqlite3 function calls resolved to a different version of SQLite?

我正在尝试为Firefox 3.6制作一个XPCOM组件。*。它使用静态编译的libsqlite3版本3.7.4(与程序无关的代码生成 - -fPIC编译器选项)。我面临的问题是,一旦Firefox加载组件并开始执行,sqlite3_libversion_number()返回3007001,而宏SQLITE_LIBVERSION_NUMBER定义为3007004.我很确定我正在链接正确的静态sqlite3库。 ..但我怎么能仔细检查这个?生成的共享对象的ldd输出不会将libsqlite3.so列为依赖项(尽管libxul.so用于创建XPCOM组件,但使用libsqlite3.so)。如何将所有sqlite3函数调用解析为不同版本的SQLite?

PS: Is it because the libraries are compiled with -fPIC and Firefox later loads them using dlopen?

PS:是因为库是用-fPIC编译的,后来Firefox使用dlopen加载它们?

2 个解决方案

#1


0  

I be looking at the inclusion order. I have too spent a whole day or something similar wondering why the fseek() failed, not directly on Linux but on Bada, and using Eclipse IDE. The catch was that the same function having the same signature was exported by some "beta" stage .a file from Bada SDK. And I have imported the wrong .a file firstly by accident.

我正在查看包含顺序。我花了一整天或类似的事情想知道为什么fseek()失败了,不是直接在Linux上而是在Bada上,并且使用Eclipse IDE。问题是,具有相同签名的相同功能是由Bada SDK中的某个“beta”阶段.a文件导出的。我首先偶然输入了错误的.a文件。

#2


0  

In linux, it will perform recursive symbol resolution - i.e if libxul uses libsqlite3 then firefox will indirectly resolve the symbol by including the libsqlite3 from libxul.

在linux中,它将执行递归符号解析 - 即如果libxul使用libsqlite3,则firefox将通过包含libxul中的libsqlite3来间接解析符号。

This is not the case in AIX machine - where recursive symbol resolution (based on dependent libraries) will not be done.

在AIX机器中不是这种情况 - 不会进行递归符号解析(基于依赖库)。

This might not be the actual problem - but worth checking.

这可能不是实际问题 - 但值得检查。

Also check if sqlite3 is backward compatible (which I suppose is), then you can link libxul and other libraries to latest version of sqlite3.

还要检查sqlite3是否向后兼容(我认为是),然后你可以将libxul和其他库链接到最新版本的sqlite3。

#1


0  

I be looking at the inclusion order. I have too spent a whole day or something similar wondering why the fseek() failed, not directly on Linux but on Bada, and using Eclipse IDE. The catch was that the same function having the same signature was exported by some "beta" stage .a file from Bada SDK. And I have imported the wrong .a file firstly by accident.

我正在查看包含顺序。我花了一整天或类似的事情想知道为什么fseek()失败了,不是直接在Linux上而是在Bada上,并且使用Eclipse IDE。问题是,具有相同签名的相同功能是由Bada SDK中的某个“beta”阶段.a文件导出的。我首先偶然输入了错误的.a文件。

#2


0  

In linux, it will perform recursive symbol resolution - i.e if libxul uses libsqlite3 then firefox will indirectly resolve the symbol by including the libsqlite3 from libxul.

在linux中,它将执行递归符号解析 - 即如果libxul使用libsqlite3,则firefox将通过包含libxul中的libsqlite3来间接解析符号。

This is not the case in AIX machine - where recursive symbol resolution (based on dependent libraries) will not be done.

在AIX机器中不是这种情况 - 不会进行递归符号解析(基于依赖库)。

This might not be the actual problem - but worth checking.

这可能不是实际问题 - 但值得检查。

Also check if sqlite3 is backward compatible (which I suppose is), then you can link libxul and other libraries to latest version of sqlite3.

还要检查sqlite3是否向后兼容(我认为是),然后你可以将libxul和其他库链接到最新版本的sqlite3。