Statically linking a library on Linux
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开发者_JS百科 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?
PS: Is it because the libraries are compiled with -fPIC and Firefox later loads them using dlopen
?
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.
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.
This is not the case in AIX machine - where recursive symbol resolution (based on dependent libraries) will not be done.
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.
精彩评论