2012-01-08 91 views
3

我正在嘗試爲我的Diskstation 1511 NAS(Intel Atom,Linux 2.6 embedded)構建一個Python mysql驅動程序。我有MySQL-python-1.2.3。雖然MySQL安裝在NAS上,但它不包含mysql_config實用程序,因此編譯完整的MySQL安裝。構建MySQL Python模塊時出錯

嘗試構建時,出現以下錯誤消息(請參閱下面的內容)。 任何幫助表示讚賞。

DiskStation> python2.6 setup.py build 
running build 
running build_py 
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.6/MySQLdb 
running build_ext 
building '_mysql' extension 
/opt/bin/gcc -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql-src/include/mysql -I/opt/include/python2.6 -c _mysql.c -o build/temp.linux-x86_64-2.6/_mysql.o 
In file included from _mysql.c:36: 
/usr/local/mysql-src/include/mysql/my_config.h:1063:1: warning: "SIZEOF_OFF_T" redefined 
In file included from /opt/include/python2.6/Python.h:8, 
       from pymemcompat.h:10, 
       from _mysql.c:29: 
/opt/include/python2.6/pyconfig.h:907:1: warning: this is the location of the previous definition 
_mysql.c: In function '_escape_item': 
_mysql.c:1050: warning: dereferencing type-punned pointer will break strict-aliasing rules 
_mysql.c: In function 'init_mysql': 
_mysql.c:2836: warning: dereferencing type-punned pointer will break strict-aliasing rules 
_mysql.c:2838: warning: dereferencing type-punned pointer will break strict-aliasing rules 
_mysql.c:2840: warning: dereferencing type-punned pointer will break strict-aliasing rules 
_mysql.c:2842: warning: dereferencing type-punned pointer will break strict-aliasing rules 
/opt/bin/gcc -shared -L/opt/lib -Wl,-rpath,/opt/lib -Wl,-rpath-link,/opt/lib build/temp.linux-x86_64-2.6/_mysql.o -L/usr/syno/mysql/lib/mysql -L/opt/lib -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -lpython2.6 -o build/lib.linux-x86_64-2.6/_mysql.so 
/opt/lib/gcc/i686-linux-gnu/4.2.1/../../../../i686-linux-gnu/bin/ld: cannot find -lmysqlclient_r 
collect2: ld returned 1 exit status 
error: command '/opt/bin/gcc' failed with exit status 1 
+0

我認爲是的線程客戶端的東西...在你site.cfg文件,你可以設置線程安全的假,看看有沒有沉默的錯誤?爲mysqlclient_r做了googling沒有返回任何有用的東西? – David 2012-01-08 11:36:16

+0

是的,這很有用,非常感謝。 – user1135334 2012-01-17 10:57:12

回答

6

我上面有同樣的錯誤。問題是它缺少一些頭文件。 Google快速顯示它需要python-dev,但它是默認的Python(2.7)。使用Python 2.6,有一個包python2.6-dev。所以,我們需要的是:

$ sudo apt-get install python2.6-dev 
+0

我有'Python2.7.2'來解決我使用過的'sudo apt-get install python2.7-dev'工作正常。 – 2013-11-13 07:00:45