Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-08

My Lazarus Dream: Cross Compile Linux64 -> Linux32 on Ubuntu 12.04

5 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexsander Rosa

Is it even possible? I've seen rumours of people doing this, but every tutorial I've tried failed.
My /etc/fpc.cfg is now an alphabet soup, my apt-get system is a mess and it sill does not work.
The setup is: Ubuntu 12.04 64-bit. It seems FPC 2.6.0 is working: the following test works:
http://wiki.freepascal.org/Cross_compiling#Cross_compiling_the_LCL

Lazarus 64-bit compiles and runs normally. Then I try on ~/lazarus: $ make all CPU_TARGET=i386
OPT="-Fu/usr/local/lib/fpc/2.6.0/units/i386-linux/*"

It compiles but does not link. The message is:

Show quoted text 32 lines
/usr/bin/fpc -Pi386 -XPi386-linux- -Xr -gl -dlclgtk2 -Fu../lcl/units/i386-linux -Fu../lcl/units/i386-linux/gtk2 -Fu../components/codetools/units/i386-linux -Fu../components/synedit/units/i386-linux -Fu../components/lazcontrols/lib/i386-linux -Fu../components/custom -Fu../components/mpaslex -Fu../ideintf/units/i386-linux -Fu../designer -Fu../debugger -Fu../debugger/frames -Fu../converter -Fu../packager -Fu../packager/frames -Fu../packager/units/i386-linux -Fu../units/i386-linux -Fuframes -Fu. -Fu/usr/local/lib/fpc/2.6.0/units/i386-linux/rtl -Fu/usr/local/lib/fpc/2.6.0/units/i386-linux/regexpr -Fiinclude -Fiinclude/linux -Fi../images -FE.. -FU../units/i386-linux -Flinclude -Fl/etc/ld.so.conf.d/*.conf -Fu/usr/local/lib/fpc/2.6.0/units/i386-linux/* -di386 lazarus.pp Free Pascal Compiler version 2.6.0 [2012/08/22] for i386 Copyright (c) 1993-2011 by Florian Klaempfl and others Target OS: Linux for i386 Compiling lazarus.pp Compiling resource ../units/i386-linux/lazarus.or Linking ../lazarus ld: warning: ../link.res contains output sections; did you forget -T? ld: cannot find -lgdk_pixbuf-2.0 ld: cannot find -lgtk-x11-2.0 ld: cannot find -lgdk-x11-2.0 ld: cannot find -lgobject-2.0 ld: cannot find -lglib-2.0 ld: cannot find -lgthread-2.0 ld: cannot find -lgmodule-2.0 ld: cannot find -lpango-1.0 ld: cannot find -latk-1.0 ld: cannot find -lcairo lazarus.pp(130,1) Error: Error while linking

When it happened with X11, the "apt-get install libx11-dev:i386" solved. However for the other libs it does not work.

Atenciosamente, Alexsander da Rosa -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120822/16d702eb/attachment.html>

Reply by email

Bernd
to Alexsander Rosa

2012/8/22 Alexsander Rosa :

Is it even possible? I've seen rumours of people doing this, but every tutorial I've tried failed.

I am successfully cross-compiling stuff (although no LCL) from Linux32 to Linux64. I assume the other way around should also be possible. It looks like you are almost there, you only need to satisfy the library dependencies.

Getting the cross compiler set up and running was easy, I did it from source, not using any apt-get at all to not compromise my system. It turned out that as and ld on Ubuntu 32 bit are already capable of working with 32 and 64 binaries, all that was needed are the correct command line switches, i found two small one-liner wrapper scripts for as and ld somewhere in the wiki. Then I got FPC working, I assume you have mastered this first step already.

The next problem are the linker errors. My concrete library that I am cross compiling (its a libpurple plugin) depends on far less libraries than lcl but I still got a whole bunch of linker errors, then I did he following:

I made a new empty folder /usr/lib64 (I guess you might want to make a folder /usr/lib32) and make sure it is on the library search path for ld, then I went through each of the errors one by one and searched which deb package (the libsomething and the corresponding libsomething-dev) would contain these libs on the target platform, downloaded the .deb and extracted them manually (NOT with dpkg!) and copied the libs (and the symlinks from the -dev packages) to my new lib folder, made sure all symlinks were working and tried to compile and link again and each time I added more needed libraries the errors got less until it finally succeeded. It looks like this is the only thing that is still missing and you are only a few hours away from success.

Reply by email

Patrick Chevalley
to leledumbo

I also have this problem since I upgrade Ubuntu to 12.04, it used to work fine with all the previous version.
The problem is because of the new multiarch system used by Ubuntu 12.04 you cannot install an i386-dev package on a x86_64 system.

This is why in the solution given by Dibo you need this tricky part: cd /usr/lib/i386-linux-gnu/
sudo ln -s libcairo.so.2 libcairo.so

Which will be normally solved by apt-get install libcairo2-dev:i386 . But if you try that he want to remove half of your system because some file are common with the x86_64 version of libcairo2-dev.

I personally solve the problem by running a i386 virtual machine.

Patrick

Reply by email