Welcome, Guest
Username: Password: Remember me
CodeTyphon Cross-Build Development, discussions and problems
  • Page:
  • 1

TOPIC:

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2382

  • Dibo
  • Dibo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1
Hi,

I have CodeTyphon installed on Ubuntu Linux 12.04 64bit. I created cross element for windows and it works perfect. But I have problem with cross element for linux 32bit (i386). It is created in CodeTyphon center but seems that compiled applications are still 64 bit, because:

1. My friend who have 32bit can't run it
2. Binary size is exactly same like for 64 bit
3. Linux command: file ./project1 return:

ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.4.0, stripped

Am I doing something wrong? What I'm doing is changing project target system and CPU to Linux i386. Must I do something else?

Codetyphon 2.80

Regards

Please Log in or Create an account to join the conversation.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2383

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Please set FPC to

/usr/lib/codetyphon/fpc/bin/x86_64-linux/fpc

from Lazarus Options and test again

The Unix CrossBuild ability at ver 2.80 is experimental,
we working for the final stage of this CT sub-system.
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2384

  • Dibo
  • Dibo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1
After this modification, when try compile project I get:

/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: warning: link.res contains output sections; did you forget -T?
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lpthread
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -ldl
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lX11
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lgdk_pixbuf-2.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lgtk-x11-2.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lgdk-x11-2.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lgobject-2.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lglib-2.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lgthread-2.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lgmodule-2.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lpango-1.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lcairo
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -latk-1.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lc

But I have all those librarys

Please Log in or Create an account to join the conversation.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2385

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

dibo wrote: After this modification, when try compile project I get:

...
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lpango-1.0
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lcairo
...

But I have all those librarys


Are you absolutely sure that you have all those libraries in both 32bit and 64bit version and not only in 64 bit version?

You need to have both versions (32bit and 64bit) - probably in /usr/lib/ and in /usr/lib64/ (or whatever those folders are called, because I am not sure what exact folder names in Ubuntu are).

I am pretty sure that your problem came from the fact that you do not have proper .so links for 32bit libraries (if you really have them installed).
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lpango-1.0
Probably means that you only have libpango-1.0.so.0.2904.0 and libpango-1.0.so.0 but no libpango-1.0.so in /usr/lib/
/usr/lib/codetyphon/fpc/bin/x86_64-linux/i386-linux-ld: cannot find -lcairo
Probably means that you only have libcairo.so.2.11000.2 and libcairo.so.2 but no libcairo.so in /usr/lib/

And you probably have same situation for other 32bit libraries that are reported to be missing.

So, please read my post in Linux development section about 32bit development in 64bit Linux. You might find something useful, even you use Ubuntu.

Please note that tutorial is made for 2.70, and most of this things are not needed anymore, but some parts are still valid.

Please pay attention to step 8 (about symbolic links).

So just do "magic" described in step 8 and enjoy in 32bit app compile on 64bit Linux! :)

Please Log in or Create an account to join the conversation.

Last edit: by Aleksandar.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2389

  • Dibo
  • Dibo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1

viking wrote: Probably means that you only have libpango-1.0.so.0.2904.0 and libpango-1.0.so.0 but no libpango-1.0.so in /usr/lib/

I have libpango-1.0.so too. Ubuntu 32 bit libs are in ia32-lib and ia32-lib-multiarch package. I tried fix described in your article (from 8 to 13). It doesn't help. I don't want break anything in my ubuntu structure, so I just install codetyphon on my 32 bit virtual mashine until someone find out what exactly do in ubuntu

Thanks anyway

Please Log in or Create an account to join the conversation.

Last edit: by Dibo.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2390

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

dibo wrote:

viking wrote: Probably means that you only have libpango-1.0.so.0.2904.0 and libpango-1.0.so.0 but no libpango-1.0.so in /usr/lib/

I have libpango-1.0.so too. Ubuntu 32 bit libs are in ia32-lib and ia32-lib-multiarch package. I tried fix described in your article (from 8 to 13). It doesn't help. I don't want break anything in my ubuntu structure, so I just install codetyphon on my 32 bit virtual mashine until someone find out what exactly do in ubuntu

Thanks anyway


Let me explain what you did following my post.

Step 8 from my post use find command to locate libs that have "." and some number after ".so" (for example to locate libcairo.so.2) then it use sed to make target name "libcairo.so" in this case. It also checks if that target file already exists or not. Only if target doesn't exist sym link is created. So it should be very safe command.

You can use #ls -lt to find which files are created when you execute the command and you can safely delete those new sym links if you want.

Steps 9 to 12 are just to make i386-linux-as and i386-linux-ld. You can delete them from /usr/bin since CT 2.80 installs them (in one of CT folders).

I would suggest you to install 64bit Ubuntu in virtual machine, and to try to figure out what is wrong if you have time (I am willing to help). You can always restore previous snapshot if something goes wrong.

If you have 32bit apps (with proper .so links), then I am not sure that your 32bit libs are visible to compiler.

Let's focus on libcairo for example.

What you get with #locate libcairo.so?

Please take a look on those two cases:

Case 1
/usr/lib/libcairo.so.2
/usr/lib/libcairo.so.2.11000.2
/usr/lib64/libcairo.so
/usr/lib64/libcairo.so.2
/usr/lib64/libcairo.so.2.11000.2

On this machine 32bit compile doesn't work, but compiled 32bit app works.

Case 2
/usr/lib/libcairo.so
/usr/lib/libcairo.so.2
/usr/lib/libcairo.so.2.11000.2
/usr/lib64/libcairo.so
/usr/lib64/libcairo.so.2
/usr/lib64/libcairo.so.2.11000.2

On this machine both 32bit compile and compiled 32bit app works.

I hope this will help at list a little.

Please Log in or Create an account to join the conversation.

Last edit: by Aleksandar.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2391

  • Dibo
  • Dibo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1
Ok. locate libcairo.so return me:

/usr/lib/conky/libcairo.so
/usr/lib/conky/libcairo.so.0.0.0
/usr/lib/i386-linux-gnu/libcairo.so.2
/usr/lib/i386-linux-gnu/libcairo.so.2.11000.2
/usr/lib/x86_64-linux-gnu/libcairo.so
/usr/lib/x86_64-linux-gnu/libcairo.so.2
/usr/lib/x86_64-linux-gnu/libcairo.so.2.11000.2

So If I understand, my 32 lib path is /usr/lib/i386-linux-gnu ? I tried call your find command in this directory but now I see it output some strange error:

sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found
sh: 1: [[: not found

Please Log in or Create an account to join the conversation.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2392

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

dibo wrote: Ok. locate libcairo.so return me:

/usr/lib/conky/libcairo.so
/usr/lib/conky/libcairo.so.0.0.0
/usr/lib/i386-linux-gnu/libcairo.so.2
/usr/lib/i386-linux-gnu/libcairo.so.2.11000.2
/usr/lib/x86_64-linux-gnu/libcairo.so
/usr/lib/x86_64-linux-gnu/libcairo.so.2
/usr/lib/x86_64-linux-gnu/libcairo.so.2.11000.2

So If I understand, my 32 lib path is /usr/lib/i386-linux-gnu ? I tried call your find command in this directory but now I see it output some strange error:

sh: 1: [[: not found
sh: 1: [[: not found


OK, now it's clear. You need to have .so links in /usr/lib/i386-linux-gnu in order to compile.

Looks like Ubuntu doesn't like bash style I used for it.

What you get when you execute those commands?

#which find
/usr/bin/find

#which sed
/bin/sed

#which [
/usr/bin/[


I see you are online, came to chat and let's try to find something else that work.

Please Log in or Create an account to join the conversation.

Last edit: by Aleksandar.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2398

  • Dibo
  • Dibo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1
Huh, finally have solution for ubuntu lib32 structure. Must say it get me crazy. I spent almost all day but it was worth it ;)

Thanks viking for your last link on chat to discussion group which has major trick
  • First, fresh (without any lib32 packages installed) Xubuntu 64 bit (virtualbox mashine) by default has /lib and /usr/lib as for 32 bit librarys. /lib/x86_64-linux-gnu and /usr/lib/x86_64-linux-gnu are for 64bit (I read that there should be lib64 dir somewhere too, but can't find it in my structure)
  • Go to Lazarus menu Tools -> Options and change fpc path from:

    /usr/lib/codetyphon/fpc/bin/x86_64-linux/ppcx64

    to:

    /usr/lib/codetyphon/fpc/bin/x86_64-linux/fpc

  • Remember to create cross element for linux-i386 in CodeTyphon center
  • Now, to compile 32 bit project we need ia32-libs package (sudo apt-get / aptitude install ia32-libs). This package create new dirs with 32 bit librarys: /lib/i386-linux-gnu and /usr/lib/i386-linux-gnu. Note that this package created new dirs different than default 32bit libs in ubuntu 64bit (solution later). Try to build 32 bit project. Still doesn't see librarys
  • On some forum I found that package g++-multilib is needed (sudo apt-get / aptitude install g++-multilib), but I think this is not necessary. This package only create another dirs /lib32 and /usr/lib32 with same librarys (but much less) like ia32-libs package. This is messy, so I removed it
  • Now, the most important change is in compiler config. By default (CodeTyphon ver. 2.80) fpc.cfg (/usr/lib/codetyphon/fpc/bin/x86_64-linux/fpc.cfg) has this path (another :S ) for i386 CPU:

    #ifdef cpui386
    -Fl/usr/lib/gcc/x86_64-linux-gnu/4.2.3
    #endif

    I changed it to dirs where ic32-libs package is installed:

    #ifdef cpui386
    -Fl/usr/lib/i386-linux-gnu
    -Fl/lib/i386-linux-gnu
    -Xd
    #endif

    I don't know what -Xd switch mean, but it was in forum where I found it
  • That's not all. ia32-libs by defaut doesn't have symlinks to simple name. For example you find there libcairo.so.2 and libcairo.so.2.11000.2 but free pascal need simple name libcairo.so. So you must create symlink for each missing library:
    cd /usr/lib/i386-linux-gnu/
    sudo ln -s libcairo.so.2 libcairo.so
    sudo ln -s libpango-1.0.so.0 libpango-1.0.so
    etc...
    Note that some librarys are in second dir (in my case 4: libglib, libdl, libpthread, libc). So analogously:
    cd /lib/i386-linux-gnu/
    sudo ln -s libpthread.so.0 libpthread.so
    .....
  • And finally when you create all symlinks, you must refresh library paths in system enviromnent:
    sudo updatedb
    Now you should be able to build your 32 bit project
This solution should work on 99% (my friend which have 32 bit linux will be tomorrow, but command "file ./project1" printing me "ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), not stripped)

Please notice that I'm not linux expert, you do this on own risk

@Viking - you could reedit your article and add this solution for ubuntu next to mandriva

So, summarizing why I couln't cross compile from 64bit linux to 32bit linux was:
  • Different paths for 32 bit libs in ubuntu distro like in others 64 bit linux distros (e.g. Mandriva)
  • Totally unknown path for 32 bit libs in default fpc.cfg (@Viking which path do you have in your fpc.cfg on mandriva?)

Thanks to all (especialy for viking taking time on chat) for amazing suppport, Regards

Please Log in or Create an account to join the conversation.

Last edit: by Dibo.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2399

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
oh my... :woohoo:
can we will use these for CT help ?
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2400

  • Dibo
  • Dibo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1
Of course, but will be nice as another ubuntu user could confirm this solution (but I worked on fresh ubuntu virtual box and noted everythin what I'm doing, so it should be no errors)

Please Log in or Create an account to join the conversation.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2401

  • Dibo
  • Dibo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1
I refreshed this solution.

BTW: Sorry for my English. Fixes welcome ;)

Please Log in or Create an account to join the conversation.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2402

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

dibo wrote: Huh, finally have solution for ubuntu lib32 structure. Must say it get me crazy. I spent almost all day but it was worth it ;)

Thanks to all (especialy for viking taking time on chat) for amazing suppport, Regards


You're welcome.

But let's clear few things. :)

1. updatedb is needed only for locate command. Locate can not find files unless you update it's database. So, updatedb is not part of solution, but it is useful in order to get proper results with locate.

2. "-Xd" is used to overcome standard library search path

3. "-Fl" is used in conjunction with "-Xd" and it points to folders that you want to use instead of default ones

4. We need to find out why my autosymlink script doesn't work in Ubuntu. It would help a lot if sym links could be created in same way as in Mandriva (Rosa). Making symlinks one by one is long task.

And now let's answer your question about config. I use default fpc.cfg

Those parts of fpc.cfg are enough in my case:
# binutils prefix for cross compiling
#IFDEF FPC_CROSSCOMPILING
  -XP$fpctarget-
#ENDIF

and
# searchpath for units and other system dependent things
-Fu/usr/lib/codetyphon/fpc/units/$fpctarget
-Fu/usr/lib/codetyphon/fpc/units/$fpctarget/*
-Fu/usr/lib/codetyphon/fpc/units/$fpctarget/rtl

This part is useless in my case
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.2.3
#endif

#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.2.3
#endif

since I do not have those folders (and obviously do not need them).

Would you please try to comment this part
#ifdef cpui386
-Fl/usr/lib/i386-linux-gnu
-Fl/lib/i386-linux-gnu
-Xd
#endif

to make it
#ifdef cpui386
#-Fl/usr/lib/i386-linux-gnu
#-Fl/lib/i386-linux-gnu
#-Xd
#endif

I have a felling that it would work without it (since those are instructions for compiler (fpc) and you had problem with a linker (ld).
The following user(s) said Thank You: FredyCC

Please Log in or Create an account to join the conversation.

Last edit: by Aleksandar.

Can't cross-compile from linux 64 bit to linux 32 12 years 3 months ago #2403

  • Dibo
  • Dibo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1
If I comment this section in fpc.cfg, then compilator doesn't see any librarys. Seems that this is important switch on ubuntu (I found it on discussion group "FPC on ubuntu")

Please Log in or Create an account to join the conversation.

  • Page:
  • 1