-1


The solution is the -I option. Include what you need as the father directory like so:

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

I guess the problem is that the directory is not declared properly. If you append the actual missing library it won't work, because it will try to access it like that:

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


I guess you already think 'Oh no, again such a nooby question, and I really wish you are right.

The problem shows as follows: I tried to

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/

and also a make of the git clone

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

Which does not work because apparently there is no such file or directory. But as you can see here:

~/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

So I had a 3 hour search on what might cause it and found different solutions, but none of them worked at all.

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

I tried with pip/3.

Because the make file didn't work either I guess it has something todo with the gcc/g++.

Thanks for the help, and I hope it might help others too.

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

Fix is now prepended, but I still wonder, why the gcc does not accept the given header files in /usr/include/ Any ideas?

Scareactor
  • 63
  • 1
  • 5

1 Answers1

-1

Since you are using includes files from openssl , u need to tell the compiler where to look for Include files using option -I

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

The above most probably should remove that error . Make sure u add all include files with g++ option -I .

Sanjay
  • 127
  • 7