gcc .h没有这样的文件或目录(openssl,anaconda,Ubuntu 18.04 [复制]

问题描述 投票:-1回答:1


解决方案是-I选项。包括你需要的父目录,如下所示:

pip install --global-option=build_ext --global-option="-I/usr/include" hashpumpy

我想问题是目录未正确声明。如果你附加实际丢失的库它将无法工作,因为它会尝试访问它:

/usr/include/openssl/openssl/[header.h]


我猜你已经想过了'哦不,再次提出这样一个不起眼的问题,我真的希望你是对的。

问题表明如下:我试过

pip install hashpumpy

Collecting hashpumpy
  Using cached https://files.pythonhosted.org/packages/c1/21/7440b50f49b4e64a9eb66de8d6771e0eb91dfc8375f39c1e01a71570e589/hashpumpy-1.2.tar.gz
Building wheels for collected packages: hashpumpy
  Running setup.py bdist_wheel for hashpumpy ... error
  Complete output from command /home/tn/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-fls9yw7a/hashpumpy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-g1go7jma --python-tag cp36:
  running bdist_wheel
  running build
  running build_ext
  building 'hashpumpy' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  gcc -pthread -B /home/tn/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/tn/anaconda3/include/python3.6m -c SHA256.cpp -o build/temp.linux-x86_64-3.6/SHA256.o
  cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
  In file included from SHA256.cpp:1:0:
  SHA256.h:5:10: fatal error: openssl/sha.h: No such file or directory
   #include <openssl/sha.h>
            ^~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for hashpumpy
  Running setup.py clean for hashpumpy
Failed to build hashpumpy
Installing collected packages: hashpumpy
  Running setup.py install for hashpumpy ... error
    Complete output from command /home/tn/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-fls9yw7a/hashpumpy/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-record-y2os7_0x/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'hashpumpy' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -B /home/tn/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/tn/anaconda3/include/python3.6m -c SHA256.cpp -o build/temp.linux-x86_64-3.6/SHA256.o
    cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
    In file included from SHA256.cpp:1:0:
    SHA256.h:5:10: fatal error: openssl/sha.h: No such file or directory
     #include <openssl/sha.h>
              ^~~~~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/home/tn/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-fls9yw7a/hashpumpy/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-record-y2os7_0x/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-fls9yw7a/hashpumpy/

还有一个git克隆的品牌

g++ -c -Wall main.cpp
main.cpp:3:10:fatal error: openssl/sha.h: No such file or directory
 #include <openssl/sha.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
makefile:11: recipe for target &apos;main.o&apos; failed
make: *** [main.o] Error 1

哪个不起作用,因为显然没有这样的文件或目录。但正如你在这里看到的:

~/anaconda3/include/openssl 
aes.h       blowfish.h  cmac.h      crypto.h   dso.h     ec.h      hmac.h      md4.h      obj_mac.h      pem2.h    rand.h    safestack.h  ssl23.h  symhacks.h   ui.h
asn1.h      bn.h        cms.h       des.h      dtls1.h   engine.h  idea.h      md5.h      ocsp.h         pem.h     rc2.h     seed.h       ssl2.h   tls1.h       whrlpool.h
asn1_mac.h  buffer.h    comp.h      des_old.h  ebcdic.h  e_os2.h   krb5_asn.h  mdc2.h     opensslconf.h  pkcs12.h  rc4.h     sha.h        ssl3.h   ts.h         x509.h
asn1t.h     camellia.h  conf_api.h  dh.h       ecdh.h    err.h     kssl.h      modes.h    opensslv.h     pkcs7.h   ripemd.h  srp.h        ssl.h    txt_db.h     x509v3.h
bio.h       cast.h      conf.h      dsa.h      ecdsa.h   evp.h     lhash.h     objects.h  ossl_typ.h     pqueue.h  rsa.h     srtp.h       stack.h  ui_compat.h  x509_vfy.h

ls /usr/include/openssl 
aes.h       bio.h       cast.h      conf.h    dsa.h     ec.h      hmac.h   md4.h      obj_mac.h   pem.h     rc4.h        seed.h  ssl3.h      ts.h        x509v3.h
asn1.h      blowfish.h  cmac.h      crypto.h  dtls1.h   engine.h  idea.h   md5.h      ocsp.h      pkcs12.h  rc5.h        sha.h   ssl.h       txt_db.h    x509_vfy.h
asn1_mac.h  bn.h        cms.h       ct.h      ebcdic.h  e_os2.h   kdf.h    mdc2.h     opensslv.h  pkcs7.h   ripemd.h     srp.h   stack.h     ui.h
asn1t.h     buffer.h    comp.h      des.h     ecdh.h    err.h     lhash.h  modes.h    ossl_typ.h  rand.h    rsa.h        srtp.h  symhacks.h  whrlpool.h
async.h     camellia.h  conf_api.h  dh.h      ecdsa.h   evp.h     md2.h    objects.h  pem2.h      rc2.h     safestack.h  ssl2.h  tls1.h      x509.h

所以我对可能导致它的原因进行了3个小时的搜索并找到了不同的解决方案,但它们都没有工作。

apt install libssl-dev

pip install --user --global-option=build_ext --global-option="-ldl" --global-option="-lcrypto" --global-option="-lssl" hashpumpy

pip install --user --global-option=build_ext --global-option="-L/usr/include/openssl

我试着用pip / 3。

因为make文件不起作用,我猜它有与gcc / g ++有关的东西。

感谢您的帮助,我希望它也可以帮助其他人。

which gcc 
/home/tn/anaconda3/bin/gcc


which g++
/home/tn/anaconda3/bin/g++

which pip
/home/tn/anaconda3/bin/pip

conda list | grep ssl                                                                                          
openssl                   1.0.2p               h14c3975_0  
pyopenssl                 17.5.0           py36h20ba746_0  
r-openssl                 0.9.9           mro343h086d26f_0    r

现在修复了,但我仍然想知道,为什么gcc不接受/ usr / include / Any中的给定头文件?

linux gcc openssl pip anaconda
1个回答
-1
投票

由于您正在使用来自openssl的包含文件,因此您需要告诉编译器在哪里查找使用选项-I包含文件

g++ -I ~/anaconda3/include/openssl  -c -Wall main.cpp

以上最有可能应该删除该错误。确保使用g ++选项-I添加所有包含文件。

© www.soinside.com 2019 - 2024. All rights reserved.