Welcome, Guest
Username: Password: Remember me
CodeTyphon Linux OS Development, discussions and problems
  • Page:
  • 1

TOPIC:

BOTH 32 and 64bit Lazarus in Mandriva and ROSA x64 12 years 4 months ago #2268

  • Aleksandar
  • Aleksandar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31
Please note that tutorial is made for 2.70, and most of this things are not needed anymore!

Please read updated tutorial available here



As I promised, here is a little guide to help you compile and run both 32bit and 64bit Lazarus in Mandriva and ROSA.

You should be able to compile for those 4 targets, even if you do not install 32bit Lazarus:

1. x86_64-linux
2. i386-linux
3. x86_64-win64
4. i386-win32

Mandriva and ROSA are both dualarc (means that they can run 32 and 64bit apps in 64bit OS), but both of those distributions need a little push in order to became usable for dual CT.

As we all know official CT way is to have both 64bit and 32bit Lazarus on 64bit machine. On the other hand I want to use only one 64bit Lazarus for compiling of both 32bit and 64bit apps.

Please note that this is not a perfect way to accomplish dual CT compiling on Linux, but it works.

In addition, it is also possible to make this to compile Windows apps (both 32bit and 64bit), but I will leave that for some other post (in next few days).


1. Add yourself to the "wheel" group if you are not already part of that group.
usermod -aG wheel your_user

Log out and log in again to make this change active. This is clean and proper way to add yourself to sudo users.

2. If you do not want to enter password for sudo every time, open console, and type
sudo visudo
and enter your password. Comment line
%wheel ALL=(ALL) ALL
and uncomment line
%wheel ALL=(ALL) NOPASSWD: ALL

3. Now it is time to add repositories in order to update your system. I also added 32bit repositories (since we want to compile for 32bit too). Only Main 32 release and update are active. MIB repositories are included too (not needed for CT, but very useful for yourself.

FOR ROSA 2012
sudo urpmi.removemedia -a
sudo urpmi.addmedia Main_64_release http://mirrors.coreix.net/rosa/rosa2012lts/x86_64/media/main/release/
sudo urpmi.addmedia --update Main_64_updates http://mirrors.coreix.net/rosa/rosa2012lts/x86_64/media/main/updates/
sudo urpmi.addmedia Contrib_64_release http://mirrors.coreix.net/rosa/rosa2012lts/x86_64/media/contrib/release/
sudo urpmi.addmedia --update Contrib_64_updates http://mirrors.coreix.net/rosa/rosa2012lts/x86_64/media/contrib/updates/
sudo urpmi.addmedia NonFree_64_release http://mirrors.coreix.net/rosa/rosa2012lts/x86_64/media/non-free/release/
sudo urpmi.addmedia --update NonFree_64_updates http://mirrors.coreix.net/rosa/rosa2012lts/x86_64/media/non-free/updates/
sudo urpmi.addmedia Restricted_64_release http://mirrors.coreix.net/rosa/rosa2012lts/x86_64/media/restricted/release/
sudo urpmi.addmedia --update Restricted_64_updates http://mirrors.coreix.net/rosa/rosa2012lts/x86_64/media/restricted/updates/
sudo urpmi.addmedia --update MIB-basic_64 http://mirrors.coreix.net/MIB/rosa2012lts/64/basic/
sudo urpmi.addmedia --raw --update MIB-experts_64 http://mirrors.coreix.net/MIB/rosa2012lts/64/experts/
#
sudo urpmi.addmedia Main_32_release http://mirrors.coreix.net/rosa/rosa2012lts/i586/media/main/release/
sudo urpmi.addmedia --update Main_32_updates http://mirrors.coreix.net/rosa/rosa2012lts/i586/media/main/updates/
sudo urpmi.addmedia --raw Contrib_32_release http://mirrors.coreix.net/rosa/rosa2012lts/i586/media/contrib/release/
sudo urpmi.addmedia --raw --update Contrib_32_updates http://mirrors.coreix.net/rosa/rosa2012lts/i586/media/contrib/updates/
sudo urpmi.addmedia --raw NonFree_32_release http://mirrors.coreix.net/rosa/rosa2012lts/i586/media/non-free/release/
sudo urpmi.addmedia --raw --update NonFree_32_updates http://mirrors.coreix.net/rosa/rosa2012lts/i586/media/non-free/updates/
sudo urpmi.addmedia --raw Restricted_32_release http://mirrors.coreix.net/rosa/rosa2012lts/i586/media/restricted/release/
sudo urpmi.addmedia --raw --update Restricted_32_updates http://mirrors.coreix.net/rosa/rosa2012lts/i586/media/restricted/updates/
sudo urpmi.addmedia --raw --update MIB-basic_32 http://mirrors.coreix.net/MIB/rosa2012lts/32/basic/
#

FOR MANDRIVA 2011
sudo urpmi.removemedia -a
sudo urpmi.addmedia Main_64_release ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/main/release
sudo urpmi.addmedia --update Main_64_updates ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/main/updates
sudo urpmi.addmedia --update Main_64_backports ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/main/backports
sudo urpmi.addmedia Contrib_64_release ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/contrib/release
sudo urpmi.addmedia --update Contrib_64_updates ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/contrib/updates
sudo urpmi.addmedia --update Contrib_64_backports ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/contrib/backports
sudo urpmi.addmedia NonFree_64_release ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/non-free/release
sudo urpmi.addmedia --update NonFree_64_updates ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/non-free/updates
sudo urpmi.addmedia --update NonFree_64_backports ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/x86_64/media/non-free/backports
sudo urpmi.addmedia --update MDV-restricted_64 http://mirror.yandex.ru/mandriva/official/restricted/2011.0/x86_64/
sudo urpmi.addmedia --update MIB-basic_64 http://mib.pianetalinux.org/MIB/2011.0/64/basic/
sudo urpmi.addmedia --update --raw MIB-experts_64 http://mib.pianetalinux.org/MIB/2011.0/64/experts/
#
sudo urpmi.addmedia Main_32_release ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/i586/media/main/release
sudo urpmi.addmedia --update Main_32_updates ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/i586/media/main/updates
sudo urpmi.addmedia --update Main_32_backports ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/i586/media/main/backports
sudo urpmi.addmedia --raw Contrib_32_release ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/i586/media/contrib/release
sudo urpmi.addmedia --update --raw Contrib_32_updates ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/i586/media/contrib/updates
sudo urpmi.addmedia --update --raw Contrib_32_backports ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2011/i586/media/contrib/backports
sudo urpmi.addmedia --update --raw MDV-restricted_32 http://mirror.yandex.ru/mandriva/official/restricted/2011.0/i586/
sudo urpmi.addmedia --update --raw MIB-basic_32 http://mib.pianetalinux.org/MIB/2011.0/32/basic/
# 

4. Now it is time to update all.
sudo urpmi --auto-update

That was standard and usual part.

Real fun begins here. ;)

You can try something similar on other distributions too, but I can not guaranty that it will work.

5. Install 32bit OpenGL Extension to GTK+2
sudo urpmi libgtkglext1

6. Next step is to make 32bit apps looks same as 64bit apps.
sudo urpmi libcanberra-gtk0
sudo urpmi libmurrine

7. I am sure that I had to add this library On Mandriva, but in ROSA it was installed in step 5, so use this only if needed.
sudo urpmi libgtk-aurora-engine-1

8. This is the trickiest part. You need to fix all missing 32bit symbolic links. You can lost days trying to do that checking file by file and making symbolic links one by one, or you can use a little magic for that. :)
cd /lib
find *.so.? -exec sh -c '[[ ! -f `echo {} | sed 's/\.so\.[0-9]/\.so/'` ]] && [[ ! -h `echo {} | sed 's/\.so\.[0-9]/\.so/'` ]] && sudo ln -s {} `echo {} | sed 's/\.so\.[0-9]/\.so/'`' \;

cd /usr/lib
find *.so.? -exec sh -c '[[ ! -f `echo {} | sed 's/\.so\.[0-9]/\.so/'` ]] && [[ ! -h `echo {} | sed 's/\.so\.[0-9]/\.so/'` ]] && sudo ln -s {} `echo {} | sed 's/\.so\.[0-9]/\.so/'`' \;

Now I feel like Harry Potter and you are ready to compile both 64bit and 32bit apps. :woohoo:

9. Make as and ld ready for cross compile. Create i386-linux-ld and i386-linux-as.
sudo touch /usr/bin/i386-linux-as
sudo touch /usr/bin/i386-linux-ld

I forgot to add next three steps in original posts, so I am adding them now.

10. Edit /usr/bin/i386-linux-as like this
#!/bin/bash
as --32 $@

11. Edit /usr/bin/i386-linux-ld like this
#!/bin/bash
ld -A elf32-i386 $@

12. Make i386-linux-as and i386-linux-ld executable
sudo chmod +x /usr/bin/i386-linux-as
sudo chmod +x /usr/bin/i386-linux-ld

Finally, it is time to download and unpack CodeTyphon.

Form this point you can follow one of two paths. You need to decide which one will you follow.

A - Compile both 64bit and 32bit Lazarus

Open "ln_All_Functions.sh" and change those lines
if [ $(uname) = "SunOS" ] ; 
then  
  vsysfpc32sub=1
  vsyslaz32sub=1
fi

to
if [ $(uname) = "SunOS" -o -f /etc/mandriva-release ] ; 
then  
  vsysfpc32sub=1
  vsyslaz32sub=1
fi

B - Compile only 64bit Lazarus

Open "ln_All_Functions.sh" and change those lines
if [ -f /etc/SuSE-release ] ;
then   
  vsysfpc32sub=1
  vsyslaz32sub=0
fi

to
if [ -f /etc/SuSE-release -o -f /etc/mandriva-release ] ;
then   
  vsysfpc32sub=1
  vsyslaz32sub=0
fi

Install CT as usual.

IMPORTANT NOTE. DO NOT TRY TO RECOMPILE LCL, this is obsolete action in latest versions of Lazarus.

If you followed path A - now you have both 32bit and 64bit FPC and both 32bit and 64bit Lazarus. :woohoo:

The only problem is that I do not know how to install 32bit GDB. :blush:

If you followed path B - now you have both 32bit and 64bit FPC but only one 64bit Lazarus. :woohoo:

At this moment you can only compile 64bit Lazarus apps, but FPC can compile both 64bit and 32bit.

I know I promised you 32bit Lazarus apps too, but that requires a touch of magic again. :)

B1. Start lazarus. Go to Tools and click on Options. Find Environment and then Files.

Change Compiler path line. Replace
/usr/lib/codetyphon/fpc/bin/x86_64-linux/ppcx64
with
/usr/lib/codetyphon/fpc/bin/$(TargetCPU)-linux/fpc

Now you can compile both 32bit and 64bit apps from one single 64bit Lazarus. This is what I use.

I really do not have enough strength to write more at this moment. Info about Windows compiling comes soon.
The following user(s) said Thank You: Konstantinos Papadoulas, FredyCC

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

Last edit: by Aleksandar.

BOTH 32 and 64bit Lazarus in Mandriva and ROSA x64 12 years 4 months ago #2274

  • Aleksandar
  • Aleksandar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31
Welcome to part II.

Now I will show you how to cross compile for Windows (also for both 32bit and 64bit).

Please read carefully and if you already read first part, read it again, since I slightly changed some things.

IMPORTANT NOTE! Open one console and DO NOT CLOSE IT until you finish, or you will lose path to MAKE utility that is needed for this. su -c is used instead of sudo for same reason.

You will need to enter your password for both su -c commands.

1. This is very important part. Add bin folder to your path.
export PATH=$PATH:/usr/lib/codetyphon/bin/binfpc/x86_64-linux/bin

2. Go to sources folder
cd /usr/lib/codetyphon/fpcsrc/

3. Compile Windows 32bit cross compile part and put it in newfpc folder
make clean all OS_TARGET=win32 CPU_TARGET=i386 FPC=ppc386
su -c "make crossinstall OS_TARGET=win32 CPU_TARGET=i386 FPC=ppc386 INSTALL_PREFIX=/usr/lib/codetyphon/fpc/newfpc/"
make clean OS_TARGET=win32 CPU_TARGET=i386 FPC=ppc386

4. Compile Windows 64bit cross compile part and put it in newfpc folder
make clean all OS_TARGET=win64 CPU_TARGET=x86_64 FPC=ppcx64
su -c "make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 FPC=ppcx64 INSTALL_PREFIX=/usr/lib/codetyphon/fpc/newfpc/"
make clean OS_TARGET=win64 CPU_TARGET=x86_64 FPC=ppcx64

5.Move units to apropriate place
sudo mv /usr/lib/codetyphon/fpc/newfpc/lib/fpc/2.7.1/units/* /usr/lib/codetyphon/fpc/units/

6. Move cross compilers to appropriate folders.
sudo mv /usr/lib/codetyphon/fpc/newfpc/lib/fpc/2.7.1/ppcross386 /usr/lib/codetyphon/fpc/bin/i386-linux/
sudo mv /usr/lib/codetyphon/fpc/newfpc/lib/fpc/2.7.1/ppcrossx64 /usr/lib/codetyphon/fpc/bin/x86_64-linux/

7. Remove temporary folder newfpc.
sudo rm -rf /usr/lib/codetyphon/fpc/newfpc

IMPORTANT NOTE. DO NOT TRY TO RECOMPILE LCL, this is obsolete action in latest versions of Lazarus.
When you try to compile app for some target, Lazarus will automatically compile packages for this target.


At this moment you should be able to compile for all 4 targets:

1. x86_64-linux
2. i386-linux
3. x86_64-win64
4. i386-win32


even if you followed the B path (my way).

I really hope that this is only a temporary solution, and that we will get this feature out of the box in some future versions of CT. I also hope that those guides would also help CT team to accomplish that.

If something doesn't work, please let me know and I will try to figure out what is the problem. I will also update those two posts if needed.
The following user(s) said Thank You: Konstantinos Papadoulas, FredyCC

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

Last edit: by Aleksandar.

BOTH 32 and 64bit Lazarus in Mandriva and ROSA x64 12 years 4 months ago #2275

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4537
  • Thank you received: 1115
Thanks Sir
we will put your work to CT

Oh, last but not least, my respect...
PilotLogic Architect and Core Programmer

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

Last edit: by Sternas Stefanos.

BOTH 32 and 64bit Lazarus in Mandriva and ROSA x64 12 years 4 months ago #2276

  • Aleksandar
  • Aleksandar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31
Unfortunately dual compile for Linux is (at least for now) only possible if you use GTK. For Qt you can only compile 64 bit apps. :S

Looks like Qt libraries have some conflict between 32bit and 64bit Qt packages.

You need to install qt-devel and qt4pas packages.

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

BOTH 32 and 64bit Lazarus in Mandriva and ROSA x64 12 years 4 months ago #2290

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

viking wrote: Unfortunately dual compile for Linux is (at least for now) only possible if you use GTK. For Qt you can only compile 64 bit apps. :S


I just noticed that CT compiles qt4pas for Chakra Linux instead of installing the package.

So, probably it would be possible to compile qt4pas for both 64 and 32bit.

Dual Qt will make this tutorial complete, so I will try that over weekend and I will share the results with you.

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

  • Page:
  • 1