102 Record count: 5]]></m:pre> |
102 Record count: 5]]></m:pre> |
103 |
103 |
104 |
104 |
105 <p>That would not be possible with older versions of the SQLite library – as we can check by unsetting the <code>LD_PRELOAD</code> variable:</p> |
105 <p>That would not be possible with older versions of the SQLite library – as we can check by unsetting the <code>LD_PRELOAD</code> variable:</p> |
106 <m:pre jazyk="bash"><![CDATA[unset LD_PRELOAD]]></m:pre> |
106 <m:pre jazyk="bash"><![CDATA[unset LD_PRELOAD]]></m:pre> |
107 <p>Which returns us to the previous state where SQLite from our distribution was used. And the calling the same SQL query leads to an error.</p> |
107 <p>Which returns us to the previous state where SQLite from our distribution was used. And then calling the same SQL query leads to an error.</p> |
108 |
108 |
109 <p> |
109 <p> |
110 The <code>LD_PRELOAD</code> hack can be used with any other software – it is not specific to <m:name/>. |
110 The <code>LD_PRELOAD</code> hack can be used with any other software – it is not specific to <m:name/>. |
111 Another example is the <a href="https://mouse.globalcode.info/v_0/spacenav-hack.xhtml">Spacenav Hack</a> which bridges/translates two APIs of a library. |
111 Another example is the <a href="https://mouse.globalcode.info/v_0/spacenav-hack.xhtml">Spacenav Hack</a> which bridges/translates two APIs of a library. |
112 </p> |
112 </p> |
113 |
113 |
|
114 <p> |
|
115 n.b. if we do <code>export LD_PRELOAD</code> it will affect all programs started from given shell session |
|
116 and if we even put it in our <code>.bashrc</code>, it will affect all Bash sessions started later and programs started from them. |
|
117 Which might not be a desired behavior. So sometimes it is better to set the <code>LD_PRELOAD</code> variable only for a single command, not globally. |
|
118 This can be done through a custom wrapper script or an alias: |
|
119 </p> |
|
120 <m:pre jazyk="bash"><![CDATA[alias relpipe-tr-sql='LD_PRELOAD=~/src/sqlite/sqlite-autoconf-3300100/.libs/libsqlite3.so.0 relpipe-tr-sql']]></m:pre> |
|
121 <p>We can safely put this this line into our <code>.bashrc</code> without affecting any other software.</p> |
114 |
122 |
115 <h2>ABI compatibility</h2> |
123 <h2>ABI compatibility</h2> |
116 |
124 |
117 <p> |
125 <p> |
118 The prerequisite for such easy library swapping is the compatibility of the ABI (application binary interface). |
126 The prerequisite for such easy library swapping is the compatibility of the ABI (application binary interface). |