title: Compiling Crypto++ for armhf for cross compiling
body: <p>I want to cross compile the library crypto++ for deployment on a beaglebone running Debian. My host PC runs Ubuntu 14.04 LTS in a 64-bit configuration. </p>
  
  <p>I face the following problem when I invoke the make command from eclipse</p>
  
  <pre><code>arm-linux-gnueabihf-g++-4.8 -L/usr/include/cryptopp -o "GCMwithAES"  ./main.o   -lcryptopp
  /usr/lib/../lib/libcryptopp.so: file not recognized: File format not recognized
  </code></pre>
  
  <p>My guess is that since the compiler is configured for armhf, it cannot recognize the library that was compiled for amd64.</p>
  
  <p>I have successfully cross compiled and run standard (ie no external libraries) programs from my host PC to my target device.</p>
  
  <p>Solutions that I have tried</p>
  
  <ul>
  <li>Used libcrypto++ packages with the architecture specified as <code>armhf</code> as done in multiarch. The armhf libraries get installed ( as per apt) but I am unable to include and link my code with them. </li>
  <li>Manually try to compile the library as per the instruction given on this <a href="http://www.cryptopp.com/wiki/Linux" rel="nofollow">wiki</a>. However, I always run into errors whenever I try to compile the library.</li>
  </ul>
  
  <p>How do I install the libcryptopp libraries of the armhf architecture on my x64 based PC so I can cross compile? or is there any other way to resolve this issue.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>As suggested in the answer below I tried out the method suggested. I slightly modified the script <code>setenv-embed.sh</code> since I had <code>gcc-4.8</code> instead of <code>gcc-4.7</code>. The results of running the script are</p>
  
  <pre><code>CPP: /usr/bin/arm-linux-gnueabihf-cpp 
  CXX: /usr/bin/arm-linux-gnueabihf-g++
  AR: /usr/bin/arm-linux-gnueabihf-ar
  LD: /usr/bin/arm-linux-gnueabihf-ld
  RANLIB: /usr/bin/arm-linux-gnueabihf-gcc-ranlib-4.8
  
  ARM_EMBEDDED_TOOLCHAIN: /usr/bin
  ARM_EMBEDDED_CXX_HEADERS: /usr/arm-linux-gnueabihf/include/c++/4.8.2
  ARM_EMBEDDED_FLAGS: -march=armv7-a mfloat-abi=hard -mfpu=neon -I/usr/arm-linux-gnueabihf/include/c++/4.8.2 -I/usr/arm-linux-gnueabihf/include/c++/4.8.2/arm-linux-gnueabihf 
  ARM_EMBEDDED_SYSROOT: /usr/arm-linux-gnueabihf
  </code></pre>
  
  <p>I build the library using the make command and run into the following error</p>
  
  <pre><code>/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/‌​ld: cannot find /usr/arm-linux-gnueabihf/lib/libc.so.6 inside /usr/arm-linux-gnueabihf
  /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/‌​ld: cannot find /usr/arm-linux-gnueabihf/lib/libc_nonshared.a inside /usr/arm-linux-gnueabihf        
  /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/‌​ld: cannot find /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 inside /usr/arm-linux-gnueabihf
  </code></pre>
  
  <p>But when I open the location <code>/usr/arm-linux-gnueabihf/lib</code> I can find all the three error files mentioned above ie <code>libc.so.6</code>, <code>libc_nonshared.a</code> and <code>ld-linux-armhf.so.3</code></p>
  
  <p>As per the suggestions of @jww, I'm shifting this to a new question since I'm having trouble linking. My results here are left for completeness.</p>