且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

"找不到 -lssl;找不到 -lcrypto"安装 mysql-python 时?

更新时间:2023-11-22 21:30:58

您需要安装OpenSSL的开发库.如果您的发行版为开发库提供了单独的包,则它可以是 libssl-dev、libssl-devel.或者,如果没有,请安装完整的 openssl 包.

You need to have installed the development libraries of OpenSSL. It can be a libssl-dev, libssl-devel if your distribution provides separated packages for the dev libraries. Or install the complete openssl package if they don't.

(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...

但是,您有两条消息我没有,即:

But, there were two messages that you have that I didn't, namely:

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

如果你做了 ld -lcrypto --verboseld -lssl --verbose 不会产生这个结果:

Which if you did ld -lcrypto --verbose or ld -lssl --verbose wouldn't produce this results:

➜  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 包.

So, to fix this just make sure you have installed the libssl-dev package which provides both libraries.