3

Okay i've been battling for this for 2 days, that usually means its something too simple to realize.

I have an embedded linux system which I cross compile on my ubuntu. When compiling python, sqlite3 is not on the list of modules that have not been able to be compiled.

But, the _sqlite3.so library is not in the same location as for example json.so and ctypes.so array.so... in Python-2.6.6/build/lib.linux868-2.6/

The actual module with the init-functions etc is in the right place at : in Python-2.6.6/modules and it can also be found on the target system.

Since the so-file was missing, i tried compiling it myself as a shared library using my arm-compiler. This did not work either.

Without manually compiled so-file:

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rootfs/python/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
  File "rootfs/python/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
ImportError: /python/lib/python2.6/lib-dynload/_sqlite3.so: cannot open shared object file: No such file or directory

With the compiled shared library found at lib-dynloads:

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rootfs/python/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
  File "rootfs/python/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
ImportError: dynamic module does not define init function (init_sqlite3)

Edit: I was wondering if i had compiled the right library for sqlite3. As far as i now understand the _sqlite3.so is something the python builder makes and libsqlite3.so is the library it needs to build it? And libsqlite3.so is build from Sqlite3-source code. Am i mistaken here?

Anyone with more embedded Linux or Python experience have an idea what I am doing wrong here?

Gjordis
  • 2,540
  • 1
  • 22
  • 32

2 Answers2

1

Try to compile and install sqlite3 first on your system, and compiler python later. Or just

easy_install pysqlite
Lingfeng Xiong
  • 1,131
  • 2
  • 9
  • 25
  • By my system, you mean the embedded system or the host system? Anyways, at the moment, i have working sqlite3 on my host system, dev-files included. And on the target system, i build sqlite3 before building python and i have included that installation dir of the dummy filesystem onto sqlite module compilation searchdirs. I will have to see if that easy_install is usable on the makefile. – Gjordis Sep 13 '12 at 06:04
  • Yes, I install the sqlite3 first on directory structure I later make into the system.img – Gjordis Sep 13 '12 at 06:42
  • If your sqlite3 and it's dev files are already put into the default search path of your target system, python should enable module sqlite by default. However, if that doesn't work for ya, just try easy_istall way, or even compile pysqlite3 by yourself. – Lingfeng Xiong Sep 13 '12 at 06:47
  • Like in my code-snippets from traceback, the actual module is enabled, but during the imports, it crashes on the dynamic library import – Gjordis Sep 13 '12 at 06:56
1

Ok, figured this out. Somehow I did not manually compile the SO-file correctly. Got this to work like so:

First from setup.py , I added verbose debugging enabled for sqlite3 module. This added a printout that solved the problem:

skipping incompatible /usr/lib/libsqlite3.so
cannot find -sqlite3

That made me realize that the setup.py had chosen the first path where it found any module named sqlite3, ignoring it's architecture alltogether. Removing other search paths from the setup.py, but the one i had the ARM compiled library in, made it work. The _sqlite3.so was compiled nicely with all the other modules.

Gjordis
  • 2,540
  • 1
  • 22
  • 32