본문 바로가기

프로그램언어/python

pysqlite error [ src/connection.h error ]

sqlite을 사용하기 위해서는 pysqlite을 사용해야 합니다. ( trac 설치시 )
그런데 컴파일 도중에 error가 발생하였습니다.


In file included from src/module.c:24:
src/connection.h:26:40: error: /usr/include/python/Python.h: 그런 파일이나 디렉토리가 없습니다
src/connection.h:27:22: error: pythread.h: 그런 파일이나 디렉토리가 없습니다
src/connection.h:28:26: error: structmember.h: 그런 파일이나 디렉토리가 없습니다
In file included from src/connection.h:30,
                 from src/module.c:24:
src/cache.h:26:20: error: Python.h: 그런 파일이나 디렉토리가 없습니다
In file included from src/connection.h:30,
                 from src/module.c:24:
src/cache.h:34: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
src/cache.h:44: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
src/cache.h:61: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pysqlite_NodeType’
src/cache.h:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pysqlite_CacheType’
src/cache.h:64: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/cache.h:64: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/cache.h:67: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/cache.h:67: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/cache.h:69: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
In file included from src/connection.h:31,
                 from src/module.c:24:
src/module.h:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:33: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:36: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:39: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:41: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:44: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.h:51: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
In file included from src/module.c:24:
src/connection.h:37: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
src/connection.h:120: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pysqlite_ConnectionType’
src/connection.h:122: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/connection.h:124: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/connection.h:125: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/connection.h:126: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/connection.h:127: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/connection.h:128: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/connection.h:129: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/connection.h:130: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/connection.h:130: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/connection.h:132: error: expected declaration specifiers or ‘...’ before ‘PyObject’
In file included from src/module.c:25:
src/statement.h:36: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
src/statement.h:44: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pysqlite_StatementType’
src/statement.h:46: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/statement.h:49: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/statement.h:50: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/statement.h:52: error: expected declaration specifiers or ‘...’ before ‘PyObject’
In file included from src/module.c:26:
src/cursor.h:34: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
src/cursor.h:59: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pysqlite_CursorType’
src/cursor.h:61: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/cursor.h:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/cursor.h:63: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/cursor.h:64: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/cursor.h:65: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/cursor.h:66: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/cursor.h:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/cursor.h:68: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/cursor.h:69: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
In file included from src/module.c:28:
src/prepare_protocol.h:30: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
src/prepare_protocol.h:33: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pysqlite_PrepareProtocolType’
src/prepare_protocol.h:35: error: expected declaration specifiers or ‘...’ before ‘PyObject’
src/prepare_protocol.h:35: error: expected declaration specifiers or ‘...’ before ‘PyObject’
In file included from src/module.c:29:
src/microprotocols.h:33: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/microprotocols.h:44: error: expected ‘)’ before ‘*’ token
src/microprotocols.h:46: error: expected ‘)’ before ‘*’ token
src/microprotocols.h:47: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/microprotocols.h:50: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
In file included from src/module.c:30:
src/row.h:30: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
src/row.h:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pysqlite_RowType’
src/module.c:42: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.c:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.c:50: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.c:84: error: expected ‘)’ before string constant
src/module.c:90: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.c:115: error: expected ‘)’ before string constant
src/module.c:120: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.c:144: error: expected ‘)’ before string constant
src/module.c:150: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.c:176: error: expected ‘)’ before string constant
src/module.c:180: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.c:209: error: expected ‘)’ before string constant
src/module.c:213: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/module.c:224: error: expected ‘)’ before string constant
src/module.c:228: error: expected ‘)’ before ‘*’ token
src/module.c:238: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘module_methods’
src/module.c:304: error: ‘NULL’ undeclared here (not in a function)
src/module.c:307: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘init_sqlite’
error: command 'gcc' failed with exit status 1


rpm 으로 설치 하였기 때문에 문제가 없다고만 생각했습니다.
하지만 python-dev을 설치를 안하면 다음과 같은 error가 발생하는 것을 알았습니다.

python setup.py build_static install
running build_static
running build_py
running build_ext
building 'pysqlite2._sqlite' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/module.c -o build/temp.linux-x86_64-2.6/src/module.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/connection.c -o build/temp.linux-x86_64-2.6/src/connection.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/cursor.c -o build/temp.linux-x86_64-2.6/src/cursor.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/cache.c -o build/temp.linux-x86_64-2.6/src/cache.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/microprotocols.c -o build/temp.linux-x86_64-2.6/src/microprotocols.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/prepare_protocol.c -o build/temp.linux-x86_64-2.6/src/prepare_protocol.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/statement.c -o build/temp.linux-x86_64-2.6/src/statement.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/util.c -o build/temp.linux-x86_64-2.6/src/util.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c src/row.c -o build/temp.linux-x86_64-2.6/src/row.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -Iamalgamation -I/usr/include/python -I/usr/include/python2.6 -c amalgamation/sqlite3.c -o build/temp.linux-x86_64-2.6/amalgamation/sqlite3.o
amalgamation/sqlite3.c: In function ‘porter_stemmer’:
amalgamation/sqlite3.c:113808: warning: value computed is not used
amalgamation/sqlite3.c:113812: warning: value computed is not used
amalgamation/sqlite3.c:113825: warning: value computed is not used
amalgamation/sqlite3.c:113830: warning: value computed is not used
amalgamation/sqlite3.c:113836: warning: value computed is not used
amalgamation/sqlite3.c:113841: warning: value computed is not used
amalgamation/sqlite3.c:113850: warning: value computed is not used
amalgamation/sqlite3.c:113857: warning: value computed is not used
amalgamation/sqlite3.c:113900: warning: value computed is not used
amalgamation/sqlite3.c:113920: warning: value computed is not used
In function ‘memset’,
    inlined from ‘exprDup’ at amalgamation/sqlite3.c:69768:
/usr/include/bits/string3.h:82: warning: call to ‘__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters
amalgamation/sqlite3.c: In function ‘ChooseLeaf’:
amalgamation/sqlite3.c:120883: warning: ‘fMinArea’ may be used uninitialized in this function
amalgamation/sqlite3.c:120882: warning: ‘fMinGrowth’ may be used uninitialized in this function
amalgamation/sqlite3.c:120880: warning: ‘iBest’ may be used uninitialized in this function
amalgamation/sqlite3.c: In function ‘removeNode’:
amalgamation/sqlite3.c:121667: warning: ‘pParent’ may be used uninitialized in this function
gcc -pthread -shared build/temp.linux-x86_64-2.6/src/module.o build/temp.linux-x86_64-2.6/src/connection.o build/temp.linux-x86_64-2.6/src/cursor.o build/temp.linux-x86_64-2.6/src/cache.o build/temp.linux-x86_64-2.6/src/microprotocols.o build/temp.linux-x86_64-2.6/src/prepare_protocol.o build/temp.linux-x86_64-2.6/src/statement.o build/temp.linux-x86_64-2.6/src/util.o build/temp.linux-x86_64-2.6/src/row.o build/temp.linux-x86_64-2.6/amalgamation/sqlite3.o -L/usr/lib/python2.6 -L/usr/lib64 -lpython2.6 -o build/lib.linux-x86_64-2.6/pysqlite2/_sqlite.so
running install
running build
running install_lib
creating /usr/local/lib64/python2.6/site-packages/pysqlite2
creating /usr/local/lib64/python2.6/site-packages/pysqlite2/test
creating /usr/local/lib64/python2.6/site-packages/pysqlite2/test/py25
copying build/lib.linux-x86_64-2.6/pysqlite2/test/py25/py25tests.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test/py25
copying build/lib.linux-x86_64-2.6/pysqlite2/test/py25/__init__.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test/py25
copying build/lib.linux-x86_64-2.6/pysqlite2/test/dbapi.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/test/userfunctions.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/test/types.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/test/dump.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/test/regression.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/test/hooks.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/test/factory.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/test/transactions.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/test/__init__.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2/test
copying build/lib.linux-x86_64-2.6/pysqlite2/dbapi2.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2
copying build/lib.linux-x86_64-2.6/pysqlite2/dump.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2
copying build/lib.linux-x86_64-2.6/pysqlite2/_sqlite.so -> /usr/local/lib64/python2.6/site-packages/pysqlite2
copying build/lib.linux-x86_64-2.6/pysqlite2/__init__.py -> /usr/local/lib64/python2.6/site-packages/pysqlite2
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/py25/py25tests.py to py25tests.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/py25/__init__.py to __init__.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/dbapi.py to dbapi.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/userfunctions.py to userfunctions.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/types.py to types.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/dump.py to dump.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/regression.py to regression.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/hooks.py to hooks.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/factory.py to factory.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/transactions.py to transactions.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/test/__init__.py to __init__.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/dbapi2.py to dbapi2.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/dump.py to dump.pyc
byte-compiling /usr/local/lib64/python2.6/site-packages/pysqlite2/__init__.py to __init__.pyc
running install_data
creating /usr/local/pysqlite2-doc
copying doc/install-source.txt -> /usr/local/pysqlite2-doc
creating /usr/local/pysqlite2-doc/code
running install_egg_info
Writing /usr/local/lib64/python2.6/site-packages/pysqlite-2.6.3-py2.6.egg-info


수정을 했는데도 계속적으로 error가 발생하였다면
setup.cfg 파일을 열어
[build_ext]
#define=
include_dirs=/usr/include/python
library_dirs=/usr/lib/python2.6
libraries=sqlite3
#define=SQLITE_OMIT_LOAD_EXTENSION

경로에 해당하는 링크를 걸어주면 됩니다.