centos为啥安装libhiredis-dev
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos为啥安装libhiredis-dev相关的知识,希望对你有一定的参考价值。
参考技术A 1、linux下如何安装hiredis1)下载地址
https://github.com/redis/hiredis
2)编译和安装
解压后的文件夹执行 make;make install;
3)头文件包含
include <hiredis/hiredis.h>
4)编译选项
makefile文件中加入 LDFLAGS = -lhiredis
2、主要结构
主要关注2个结构体,
1)redisContext
//对应与Redis的连接
[cpp] view plain copy
/* Context for a connection to Redis */
typedef struct redisContext
int err; /* Error flags, 0 when there is no error */
char errstr[128]; /* String representation of error when applicable */
int fd;
int flags;
char *obuf; /* Write buffer */
redisReader *reader; /* Protocol reader */
enum redisConnectionType connection_type;
struct timeval *timeout;
struct
char *host;
char *source_addr;
int port;
tcp;
struct
char *path;
unix_sock;
redisContext;
2)redisReply
//对应redis命令的回复结果
[cpp] view plain copy
/* This is the reply object returned by redisCommand() */
typedef struct redisReply
int type; /* REDIS_REPLY_* */
long long integer; /* The integer when type is REDIS_REPLY_INTEGER */
int len; /* Length of string */
char *str; /* Used for both REDIS_REPLY_ERROR and REDIS_REPLY_STRING */
size_t elements; /* number of elements, for REDIS_REPLY_ARRAY */
struct redisReply **element; /* elements vector for REDIS_REPLY_ARRAY */
redisReply;
2、主要接口
主要有4个接口,
1)redisContext* redisConnect(const char *ip, int port)
//连接redis。
2)void *redisCommand(redisContext *c, const char *format, ...);
//执行redis操作命令
3)void freeReplyObject(void *reply);
//释放执行redis操作命令回复的内存
4)void redisFree(redisContext *c);
//释放连接上下文。
3、异常处理
主要4种异常情况会出现,
1)获得的redisContext指针为null
异常处理办法:再次尝试与redis建立新的连接上下文。
2)获得的redisContext指针err不为0
异常处理办法:再次尝试与redis建立新的连接上下文。
3)获得的redisReply指针为null
异常处理办法:断开redis连接再次与redis建立连接并尝试执行命令。
4)获得的reply指针的type不是期望的类型,
异常处理办法:断开redis连接再次与redis建立连接并尝试执行命令。
至此hiredis了解完毕,接下来就可以在其他模块中调用了。
为啥我无法在我的 centos 上安装 dlib 库?
【中文标题】为啥我无法在我的 centos 上安装 dlib 库?【英文标题】:Why am I not able to install dlib library on my centos?为什么我无法在我的 centos 上安装 dlib 库? 【发布时间】:2021-10-18 07:49:22 【问题描述】:我在没有 GPU 的 centos7 服务器上安装 dlib 时遇到问题。
我浏览了互联网,但找不到有效的解决方案。
我遇到的答案之一是问题是 Python 需要使用 --enable-shared
标志编译,以便 dlib 安装成功。
但显然这应该避免,因为它可能会导致其他问题。
这是我得到的错误。
ERROR: Command errored out with exit status 1:
command: /home/biotest/test2/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-nmjzjw_2
cwd: /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/
Complete output (76 lines):
running bdist_wheel
running build
running build_py
package init file 'tools/python/dlib/__init__.py' not found (or not a regular file)
running build_ext
Building extension for Python 3.6.8 (default, Nov 16 2020, 16:55:22)
Invoking CMake setup: 'cmake /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/lib.linux-x86_64-3.6 -DPYTHON_EXECUTABLE=/home/biotest/test2/bin/python3 -DCMAKE_BUILD_TYPE=Release'
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /home/biotest/test2/bin/python3 (found version "3.6.8")
-- Found PythonLibs: python3.6m
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Failed
-- Performing Test HAS_CPP11_FLAG
-- Performing Test HAS_CPP11_FLAG - Success
-- pybind11 v2.2.4
-- Using CMake version: 3.21.1
-- Compiling dlib version: 19.22.1
CMake Error at /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/set_compiler_specific_options.cmake:50 (message):
C++11 is required to use dlib, but the version of GCC you are using is too
old and doesn't support C++11. You need GCC 4.9 or newer.
Call Stack (most recent call first):
/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/test_for_sse4/CMakeLists.txt:8 (include)
CMake Error at /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/check_if_sse4_instructions_executable_on_host.cmake:13 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/set_compiler_specific_options.cmake:13 (include)
/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/CMakeLists.txt:33 (include)
-- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeOutput.log".
See also "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 261, in <module>
'Topic :: Software Development',
File "/home/biotest/test2/lib64/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/biotest/test2/lib64/python3.6/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib64/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 134, in run
self.build_extension(ext)
File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 171, in build_extension
subprocess.check_call(cmake_setup, cwd=build_folder)
File "/usr/lib64/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/lib.linux-x86_64-3.6', '-DPYTHON_EXECUTABLE=/home/biotest/test2/bin/python3', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
----------------------------------------
ERROR: Failed building wheel for dlib
Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib
Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1:
command: /home/biotest/test2/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-sfiq9dha/install-record.txt --single-version-externally-managed --compile --install-headers /home/biotest/test2/include/site/python3.6/dlib
cwd: /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/
Complete output (78 lines):
running install
running build
running build_py
package init file 'tools/python/dlib/__init__.py' not found (or not a regular file)
running build_ext
Building extension for Python 3.6.8 (default, Nov 16 2020, 16:55:22)
Invoking CMake setup: 'cmake /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/lib.linux-x86_64-3.6 -DPYTHON_EXECUTABLE=/home/biotest/test2/bin/python3 -DCMAKE_BUILD_TYPE=Release'
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /home/biotest/test2/bin/python3 (found version "3.6.8")
-- Found PythonLibs: python3.6m
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Failed
-- Performing Test HAS_CPP11_FLAG
-- Performing Test HAS_CPP11_FLAG - Success
-- pybind11 v2.2.4
-- Using CMake version: 3.21.1
-- Compiling dlib version: 19.22.1
CMake Error at /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/set_compiler_specific_options.cmake:50 (message):
C++11 is required to use dlib, but the version of GCC you are using is too
old and doesn't support C++11. You need GCC 4.9 or newer.
Call Stack (most recent call first):
/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/test_for_sse4/CMakeLists.txt:8 (include)
CMake Error at /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/check_if_sse4_instructions_executable_on_host.cmake:13 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/set_compiler_specific_options.cmake:13 (include)
/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/CMakeLists.txt:33 (include)
-- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeOutput.log".
See also "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 261, in <module>
'Topic :: Software Development',
File "/home/biotest/test2/lib64/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/biotest/test2/lib64/python3.6/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib64/python3.6/distutils/command/install.py", line 556, in run
self.run_command('build')
File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib64/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 134, in run
self.build_extension(ext)
File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 171, in build_extension
subprocess.check_call(cmake_setup, cwd=build_folder)
File "/usr/lib64/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/lib.linux-x86_64-3.6', '-DPYTHON_EXECUTABLE=/home/biotest/test2/bin/python3', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
----------------------------------------
ERROR: Command errored out with exit status 1: /home/biotest/test2/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-sfiq9dha/install-record.txt --single-version-externally-managed --compile --install-headers /home/biotest/test2/include/site/python3.6/dlib Check the logs for full command output.
(test2) [root@localhost biotest]#
【问题讨论】:
【参考方案1】:也许你可以使用conda install dlib
conda install dlib
【讨论】:
以上是关于centos为啥安装libhiredis-dev的主要内容,如果未能解决你的问题,请参考以下文章