web-dev-qa-db-ja.com

mariaDBライブラリを使用してmysql-pythonをインストールすると、「-lsslが見つかりません; -lcryptoが見つかりません」

MariaDB 10がインストールされたUbuntu 14.04で、システム全体またはvenvにmysql-python pipをインストールするのに苦労しています。 MariaDB 5.5でも試してみましたが、同じエラーが発生しました。 Vanilla mysql-serverがインストールされている場合、この問題は発生しません。

Apt-getを使用して次のものをインストールしました。

  • ビルド必須
  • python-dev
  • libmariadbclient-dev(libmysqlclient-devのMariaDB置換)
  • python-mysqldb

もともとこれはこれをvenvにインストールする際の問題だと思っていましたが、その後mysql-pythonがシステム全体にもインストールされないことに気付きました。以下は、venvにインストールするために使用したコマンドです。

virtualenv venv
. venv/bin/activate
pip install mysql-python==1.2.5

In file included from _mysql.c:44:0:
/usr/include/mysql/my_config.h:439:0: warning: "HAVE_WCSCOLL" redefined [enabled by default]
 #define HAVE_WCSCOLL
^
In file included from /usr/include/python2.7/pyconfig.h:3:0,  
                 from /usr/include/python2.7/Python.h:8,
                 from _mysql.c:29:
/usr/include/x86_64-linux-gnu/python2.7/pyconfig.h:911:0: note: this is the location of the     previous definition
 #define HAVE_WCSCOLL 1

^x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions     -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmariadbclient_r -lpthread -lz -lm -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /root/env/bin/python -c "import setuptools, tokenize;__file__='/root/env/build/mysql-    python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-EyhO2v-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/env/include/site/python2.7 failed with error code 1 in /root/env/build/mysql-python
Storing debug log for failure in /root/.pip/pip.log
22
ModerationMike

私はあなたと同じことをしましたが、まだ問題を再現できませんでした:

(venv)➜  src  pip install mysql-python==1.2.5
Downloading/unpacking mysql-python==1.2.5
  Downloading MySQL-python-1.2.5.Zip (108kB): 108kB downloaded
  Running setup.py (path:/home/braiam/src/venv/build/mysql-python/setup.py) Egg_info for package mysql-python

Installing collected packages: mysql-python
  Running setup.py install for mysql-python
    building '_mysql' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing
    In file included from _mysql.c:44:0:
    /usr/include/mysql/my_config.h:439:0: warning: "HAVE_WCSCOLL" redefined
     #define HAVE_WCSCOLL
     ^
    In file included from /usr/include/python2.7/pyconfig.h:3:0,
                     from /usr/include/python2.7/Python.h:8,
                     from _mysql.c:29:
    /usr/include/x86_64-linux-gnu/python2.7/pyconfig.h:911:0: note: this is the location of the previous definition
     #define HAVE_WCSCOLL 1
     ^
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmariadbclient_r -lpthread -lz -lm -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/_mysql.so

Successfully installed mysql-python
Cleaning up...

しかし、私が持っていない2つのメッセージがありました。

/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto

ld -lcrypto --verboseまたはld -lssl --verboseは、この結果を生成しません。

➜  src  ld -lcrypto --verbose | grep succeeded
attempt to open //usr/lib/x86_64-linux-gnu/libcrypto.so succeeded
ld: warning: cannot find entry symbol _start; not setting start address
➜  src  ld -lssl --verbose | grep succeeded
attempt to open //usr/lib/x86_64-linux-gnu/libssl.so succeeded
ld: warning: cannot find entry symbol _start; not setting start address

したがって、これを修正するには、libssl-dev両方のライブラリを提供するパッケージ。

33
Braiam

MacOSでも同様のエラーが発生しますが、「/ usr/bin/ld:-lsslが見つかりません」はありません。

次の手順で解決しました。

ステップ1. homebrewでopensslをインストールしたことを確認します。

brew install openssl

ステップ2.ターミナルで:

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

Linuxの場合は、yum install不足しているライブラリをLIBRARY_PATHに追加します。

14
Shaofei Cheng

Debian 9.xの場合:

apt install libssl-dev

4
Dmitry Mottl

CentOSの場合:

Sudo yum install openssl-devel
2
user6389186