Need a 32-bit libssl-dev for crosscompile?
Nathan Dorfman
na at rtfm.net
Fri Feb 7 18:04:08 UTC 2014
ybeOn Tue, Feb 4, 2014 at 6:15 AM, Colin Watson <cjwatson at ubuntu.com> wrote:
> On Mon, Feb 03, 2014 at 12:55:01PM -0500, Nathan Dorfman wrote:
>> Does anyone know if it's possible to easily build a 32-bit x86 program
>> that uses OpenSSL on a 64-bit machine?
>>
>> After installing a few packages like libc6-dev-i386, lib32stdc++-dev,
>> gcc-multilib and g++-multilib, I can easily build C/C++ sources with
>> the -m32 option. Until, that is, I try to build something that uses
>> OpenSSL. I'm missing a 32-bit analog of the following file:
>>
>> libssl-dev:amd64: /usr/include/x86_64-linux-gnu/
>> openssl/opensslconf.h
>>
>> There's no lib32ssl-dev package, or anything seemingly like it,
>
> You want "libssl-dev:i386"; it's Multi-Arch: same, so you can coinstall
> it with libssl-dev:amd64. This works as of Ubuntu 13.10, though not in
> earlier releases.
Hi Colin, thanks for that! I got it to work, but it wasn't completely
smooth. I must be missing something obvious, because apt-get behaved
strangely right off the bat. Perhaps you might have some idea what
went wrong? I'm also not sure what the right way to compile/link is,
but more on that later.
On a freshly installed 13.10 amd64 system with nothing but
build-essential installed, trying to install any of libssl-dev:i386,
libc6-dev:i386 or libstdc++-4.8-dev:i386 also wanted to remove
build-essential and the native amd64 compilers:
The following packages will be REMOVED:
build-essential g++ g++-4.8 gcc gcc-4.8
The following NEW packages will be installed:
gcc-4.8-base:i386 libc6:i386 libc6-dev:i386 libgcc1:i386
linux-libc-dev:i386
If I simply add it to the command-line, as in 'apt-get install
libc6-dev:i386 build-essential', then it seems to work without
removing anything. However, on my not-so-fresh daily use system,
there's more that it wanted to remove:
The following packages will be REMOVED:
build-essential dkms dpkg-dev g++ g++-4.8 gcc-4.8-multilib
gcc-multilib hardening-includes
libghc-extensible-exceptions-dev libghc-mtl-dev
libghc-transformers-dev libghc-xmonad-contrib-dev
libghc-xmonad-dev lintian network-manager-pptp
network-manager-pptp-gnome oracle-java7-installer
oracle-jdk7-installer pptp-linux
...
$ apt-get install libc6-dev:i386 build-essential
The following packages will be REMOVED:
hardening-includes lintian oracle-java7-installer oracle-jdk7-installer
...
$ apt-get install libc6-dev:i386 build-essential lintian
.. OK! ...
Definitely doesn't feel right -- not least, I have no idea why lintian
happened to be the magic word, as none of the other three packages
depend on it ('apt-get remove lintian' doesn't mention any).
Nonetheless, if I swallow hard and proceed to install it, it "looks
okay."
> I'd also generally recommend replacing the old-style biarch packages you
> installed with their multiarch equivalents:
>
> libc6-dev-i386 -> libc6-dev:i386
> lib32stdc++-4.8-dev -> libstdc++-4.8-dev:i386
Well, I have the clean system, where no other packages were ever
installed, and now gcc/g++ -m32 -c work correctly, looking in the
right location for arch-specific includes and everything. However,
when linking (still via gcc/g++ -m32, but without the -c option) it
insists on looking in /usr/lib/x86_64-linux-gnu for implicit libraries
like -lgcc and -lstdc++; however it does correctly find everything
else in /usr/lib/i386-linux-gnu, including not only explicit things
like -lssl and -ldb, but also crt1.o.
On the other hand, it worked fine on my other system. I guess the
difference was that gcc-multilib and g++-multilib had been installed.
Sure enough, installing these made it all work, but it also pulled in
the biarch versions of everything (libc6-dev-i386, lib32stdc++-dev,
lib32gcc1-dev, and a bunch of others.)
The good news is that it seems harmless -- with both installed, the
multiarch versions in /usr/lib/i386* seem to be the ones used, not the
biarch ones in /usr/lib32. So, it looks like my builds are now working
correctly, but I still don't understand how or why, and have the
feeling that I haven't done everything correctly.
Thanks again for your time,
-nd.
More information about the ubuntu-users
mailing list