2

Following the instructions given here, I’ve downloaded the latest version of OpenSSL (openssl-1.0.1e.tar.gz) from here and installed it on Ubuntu v12.10 (32-bit).

I have a C project in Eclipse CDT (v1.2.0.201212170456) that statically links to the following two .a files:

  • home/usr/local/ssl/lib/libcrypto.a
  • home/usr/local/ssl/lib/ libssl.a

However when I build my project I get these errors:

/home/tashimaya/Applications/CodeSourcery/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/local/ssl/lib/libssl.a when searching for -lssl
/home/tashimaya/Applications/CodeSourcery/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find –lssl

My toolchain is CodeSourcery (Sourcery G++ Lite 2010q1-202) and is for 32-bit OS.

What am I doing wrong?

Compiler command line I'm using:

arm-none-linux-gnueabi-gcc -I"/path to my/include" -O0 -g3 -Wall -c -fmessage-length=0 -v -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.c"
Community
  • 1
  • 1
jpen
  • 2,129
  • 5
  • 32
  • 56
  • What's your target architecture? Is it x86? Or ARM? Are you cross-compiling? When you say Ubuntu 12.10 32-bit, is it ARM? – netcoder Mar 01 '13 at 13:53
  • My target architecture is ARM. I've installed Ubuntu on VMware running on Windows 7 32 bit machine. – jpen Mar 01 '13 at 14:02

2 Answers2

3

You have installed OpenSSL on an Ubuntu 32-bit machine (assuming x86), but are trying to link it to an ARM binary:

  • /home/tashimaya/Applications/CodeSourcery/bin/../lib/gcc/arm-none-linux-gnueabi: your ARM toolchain
  • /usr/local/ssl/lib/libssl.a: a 32-bit x86 version of OpenSSL

You will have to cross-compile OpenSSL for ARM using your ARM toolchain (i.e.: arm-none-linux-gnueabi-gcc), then you will be able to link it to an ARM binary.

netcoder
  • 66,435
  • 19
  • 125
  • 142
  • Would you be able to tell me how to build OpenSSL using arm-none-linux-gnueabi-gcc? I've tried "make CC=arm-none-linux-gnueabi-gcc" but this doesn't seem to work. – jpen Mar 01 '13 at 14:51
  • @jpen: Try providing the absolute path to the compiler. And `make clean` beforehand. – netcoder Mar 01 '13 at 14:54
0

It says that /usr/local/ssl/lib/libssl.a is not in the size expected. Try file on it to check if you compiled it in 32 or 64 bit version. And check how you are compiling your own program too. If both matches linker (ld) will link it fine.

If you compile your program into 64 bit and link it with libssl.a in 32 bit, this will not work

example:

file a.out

/* kind ofoutput */ a.out: Mach-O 64-bit executable x86_64

http://unixhelp.ed.ac.uk/CGI/man-cgi?file

Mr Bonjour
  • 3,330
  • 2
  • 23
  • 46
  • Thanks for your suggestion. Running "/usr/local/ssl/lib$ file libssl.a" gives this output "libssl.a: current ar archive". How do I get more information abou the file? – jpen Mar 01 '13 at 13:24
  • Strange that output well on mac. Then try lipo -info myFile.a, you'll get the architecture too. – Mr Bonjour Mar 01 '13 at 14:08
  • I've tried "objdump -f libcrypto.a". Looks like my libssl.a are for 32-bit so is my C project. – jpen Mar 01 '13 at 14:10
  • Are you sure they are the same architecture? Can you show the compiler actual command wich you are compiling your c code? – Mr Bonjour Mar 01 '13 at 14:27
  • Please see my original post. I've updated it with my compiler command line. I've tried running "file main.o" and I get "main.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped" – jpen Mar 01 '13 at 14:36
  • I've tried the "-m32" switch but I get this error: cc1: error: unrecognized command line option "-m32" – jpen Mar 01 '13 at 14:42
  • look at netcoder response, i think he's close to your problem. You still can check that your .o files doesn't match you libSSL.a arch with a objdump -f *.o check – Mr Bonjour Mar 01 '13 at 14:46