UnixODBC-dev安装在/usr/local/下,导致gcc报sql.h找不到

UnixODBC-dev安装在/usr/local/下,导致gcc报sql.h找不到

我当前的用例是PyODBC通过poetryJenkins 作业构建进行安装,但由于sql.h找不到而失败。

作为背景,我有两台服务器,一台 RHEL 6,一台 RHEL 7; RHEL 6 服务器安装了 unixODBC ,并可与odbc.ini中的(除其他外)以及/etc/. sql.h/usr/include/

在非工作的 RHEL 7 服务器上,帮助台人员刚刚安装了相同版本的 unixODBC-dev,并且所有文件似乎都位于/usr/local/unixODBC/.

我相信我正确地理解这/usr/local是针对手动安装的软件包,我想这是这样,但我不清楚为什么这两个安装会以不同的方式完成,最终是否有一种方法可以使事情在 RHEL 服务器上工作(或者如果做不到这一点,我可以将这句话反馈给帮助台以正确方式安装。)

编辑:按照@Stephen Kitt的建议,我回到HD,据说他们安装了yum.

现在错误不同了(而且相当长,一些看似重复的行已被剪掉以适应帖子长度):

[EnvCommandError]                                                
Command ['/var/lib/jenkins/.cache/pypoetry/virtualenvs/ds-ops-tools-py3.6/bi  
n/python', '-m', 'pip', 'install', '--no-deps', 'pyodbc==4.0.26'] errored wi  
th the following output:                                                      
Collecting pyodbc==4.0.26                                                     
  Using cached https://files.pythonhosted.org/packages/b4/41/f3eb5e56af207a8  
fcc02f1f84cc3fed9fcf315565e65f418ae815e399929/pyodbc-4.0.26.tar.gz            
Installing collected packages: pyodbc                                         
  Running setup.py install for pyodbc: started                                
    Running setup.py install for pyodbc: finished with status 'error'         
    Complete output from command /var/lib/jenkins/.cache/pypoetry/virtualenv  
s/ds-ops-tools-py3.6/bin/python -u -c "import setuptools, tokenize;__file__=  
'/tmp/pip-build-i2_4l6cq/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(  
__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, _  
_file__, 'exec'))" install --record /tmp/pip-oqv50di8-record/install-record.  
txt --single-version-externally-managed --compile --install-headers /var/lib  
/jenkins/.cache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include/site/python3  
.6/pyodbc:                                                                    
    running install                                                           
    running build                                                             
    running build_ext                                                         
    building 'pyodbc' extension                                               
    creating build                                                            
    creating build/temp.linux-x86_64-3.6                                      
    creating build/temp.linux-x86_64-3.6/src                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/buffer.cpp -o build/temp.linux-x86_64-3.6/src/buffer.o -Wno-  
write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LO  
NG -DSIZEOF_LONG_INT=8 -I/usr/include                                         
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/cnxninfo.cpp -o build/temp.linux-x86_64-3.6/src/cnxninfo.o -  
Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LON  
G_LONG -DSIZEOF_LONG_INT=8 -I/usr/include                                     
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/connection.cpp -o build/temp.linux-x86_64-3.6/src/connection  
.o -Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE  
_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include                                 
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    src/connection.cpp: In function ‘PyObject* Connection_getinfo(PyObject*,  
 PyObject*)’:                                                                 
    src/connection.cpp:835:40: warning: dereferencing type-punned pointer wi  
ll break strict-aliasing rules [-Wstrict-aliasing]                            
             SQLUINTEGER n = *(SQLUINTEGER*)szBuffer; // Does this work on P  
PC or do we need a union?                                                     
                                            ^                                 
    src/connection.cpp:848:49: warning: dereferencing type-punned pointer wi  
ll break strict-aliasing rules [-Wstrict-aliasing]                            
             result = PyInt_FromLong(*(SQLUSMALLINT*)szBuffer);               
                                                     ^                        
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/cursor.cpp -o build/temp.linux-x86_64-3.6/src/cursor.o -Wno-  
write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LO  
NG -DSIZEOF_LONG_INT=8 -I/usr/include                                         
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/errors.cpp -o build/temp.linux-x86_64-3.6/src/errors.o -Wno-  
write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LO  
NG -DSIZEOF_LONG_INT=8 -I/usr/include                                         
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/getdata.cpp -o build/temp.linux-x86_64-3.6/src/getdata.o -Wn  
o-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_  
LONG -DSIZEOF_LONG_INT=8 -I/usr/include                                       
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/params.cpp -o build/temp.linux-x86_64-3.6/src/params.o -Wno-  
write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LO  
NG -DSIZEOF_LONG_INT=8 -I/usr/include                                         
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/pyodbccompat.cpp -o build/temp.linux-x86_64-3.6/src/pyodbcco  
mpat.o -Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -D  
HAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include                             
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/pyodbcdbg.cpp -o build/temp.linux-x86_64-3.6/src/pyodbcdbg.o  
 -Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_L  
ONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include                                   
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/pyodbcmodule.cpp -o build/temp.linux-x86_64-3.6/src/pyodbcmo  
dule.o -Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -D  
HAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include                             
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/row.cpp -o build/temp.linux-x86_64-3.6/src/row.o -Wno-write-  
strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DS  
IZEOF_LONG_INT=8 -I/usr/include                                               
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -  
Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.26 -I/var/lib/jenkins/.c  
ache/pypoetry/virtualenvs/ds-ops-tools-py3.6/include -I/usr/local/include/py  
thon3.6m -c src/textenc.cpp -o build/temp.linux-x86_64-3.6/src/textenc.o -Wn  
o-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_  
LONG -DSIZEOF_LONG_INT=8 -I/usr/include                                       
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for  
 C/ObjC but not for C++ [enabled by default]                                  
    creating build/lib.linux-x86_64-3.6                                       
    g++ -pthread -shared -Wl,-rpath /usr/local/lib build/temp.linux-x86_64-3  
.6/src/buffer.o build/temp.linux-x86_64-3.6/src/cnxninfo.o build/temp.linux-  
x86_64-3.6/src/connection.o build/temp.linux-x86_64-3.6/src/cursor.o build/t  
emp.linux-x86_64-3.6/src/errors.o build/temp.linux-x86_64-3.6/src/getdata.o   
build/temp.linux-x86_64-3.6/src/params.o build/temp.linux-x86_64-3.6/src/pyo  
dbccompat.o build/temp.linux-x86_64-3.6/src/pyodbcdbg.o build/temp.linux-x86  
_64-3.6/src/pyodbcmodule.o build/temp.linux-x86_64-3.6/src/row.o build/temp.  
linux-x86_64-3.6/src/textenc.o -L/usr/lib -L/usr/local/lib -L/usr/local/lib   
-lodbc -lpython3.6m -o build/lib.linux-x86_64-3.6/pyodbc.cpython-36m-x86_64-  
linux-gnu.so -L/usr/lib64 -lodbc                                              
    /bin/ld: /usr/lib/libpython3.6m.a(abstract.o): relocation R_X86_64_32S a  
gainst symbol `_Py_NotImplementedStruct' can not be used when making a share  
d object; recompile with -fPIC                                                
    /bin/ld: /usr/lib/libpython3.6m.a(boolobject.o): relocation R_X86_64_32   
against `.data' can not be used when making a shared object; recompile with   
-fPIC                                                                         

[...]

    /bin/ld: /usr/lib/libpython3.6m.a(parser.o): relocation R_X86_64_32 agai  
nst `.rodata.str1.8' can not be used when making a shared object; recompile   
with -fPIC                                                                    
    /bin/ld: /usr/lib/libpython3.6m.a(getcompiler.o): relocation R_X86_64_32  
 against `.rodata.str1.8' can not be used when making a shared object; recom  
pile with -fPIC                                                               
    /bin/ld: final link failed: Nonrepresentable section on output            
    collect2: error: ld returned 1 exit status                                
    error: command 'g++' failed with exit status 1     

编辑:我思考这是因为我的libpython*.so文件位于/usr/local/lib而不是/usr/lib;我已经添加/usr/local/libld.so.conf运行ldconfig,但这似乎没有做任何事情。

编辑2:我发现一个建议,重命名/usr/lib/libpython3.6m.a将允许“找到”.so 文件,这似乎有效!但我仍然感到困惑,因为它首先表现出unixODBC没有与包管理器一起安装(它不是)的症状,然后是 python 没有--shared-packages启用,它确实启用了,但其他文件以某种方式覆盖了这些包。如果有人能够阐明这一点,那就太好了,但我意识到,如果不确切了解该系统的服务台工作人员是如何设置和操作的,就很难说。

答案1

您的 RHEL 6 服务器上的安装可能是使用 UnixODBC 的 RHEL 包完成的。这很容易在 RHEL 7 服务器上复制:

yum install unixODBC-devel

将安装标头、开发文件及其所有依赖项。

我们无法告诉您为什么这两种安装的执行方式不同;只有您的服务台可以做到这一点。

相关内容