Recent

Author Topic: IDE under Ubuntu Crosscompile to Windows  (Read 18187 times)

Rainer78

  • New Member
  • *
  • Posts: 10
IDE under Ubuntu Crosscompile to Windows
« on: October 13, 2016, 09:54:36 pm »
Hi,

I am very new to Lazarus, but very familiar with Delphi (by Embarcadero).

I am running on a Ubuntu 16.04.01 LTS system Lazarus. It was installed with the following command

sudo apt-get install lazarus.

This command installed fpc-3.0.0 and Lazarus 1.6

Building a sample project and running it under Ubuntu works fine. But I want to try to cross compile it for Windows (Windows 32 bit and / or Windows 64bit).

I changed the settings for the project (I have a german version of Lazarus so I don't know if the english menu entry names are correct).

Project -> Project settings -> Compiler settings -> Configurations and Targets -> Target operating system = Win32
Project -> Project settings -> Compiler settings -> Configurations and Targets -> Target CPU family = i386

At the bottom of the window is a Link "Current LCL-Widgetset". I clicked this link and on the following page I changed the LCL WidgetType to win32.

If I confirm all changes I got the following error:

Compiler /usr/bin/fpc doesn't support the target i386-win32.

After that I changed the Target operation to Win64 and the Target CPU family to x86_64. I confirmed all changes and no error appears.

But when I try to compile my "hello world" project, I got the following output message:
Fatal: Can't find unit system used by project1

I found several wiki articles, how to cross compile from Linux to Windows, but it doesn't work on my system.

In some articles, they mention the following command:
make all OS_TARGET=win32 CPU_TARGET=i386

But I get the error message, that there is no rule for "all".

Are there any required packages for Lazarus, FreePascal or Ubuntu I need to install, so I will be able to cross compile my project?

Best regards,

Rainer

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #1 on: October 14, 2016, 07:00:31 am »
I found several wiki articles, how to cross compile from Linux to Windows, but it doesn't work on my system.
Which ones don't work? If they really do, the articles need fixes, so tell us your experience precisely.

To cross compile TO windows, both 32-bit and 64-bit, no additional packages required. Every requirement is built into the compiler toolchain AND its source code, which you must build for EACH requested target first, and that what the cross compiling article should tell you how to.

bylaardt

  • Sr. Member
  • ****
  • Posts: 310
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #2 on: October 14, 2016, 06:48:03 pm »

In some articles, they mention the following command:
make all OS_TARGET=win32 CPU_TARGET=i386

But I get the error message, that there is no rule for "all".


are you in the right directory?
have you permissions?

Code: Bash  [Select][+][-]
  1.  
  2. $ cd /usr/share/fpcsrc/3.0.0
  3. $ sudo make all OS_TARGET=win32 CPU_TARGET=i386
  4.  

if you install with the .deb available from the lazarus download link page, edit yout /etc/fpc.cfg file and include the following instructions:
Code: Bash  [Select][+][-]
  1. -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget
  2. -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/*
  3. -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl
  4.  

Rainer78

  • New Member
  • *
  • Posts: 10
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #3 on: October 14, 2016, 08:19:59 pm »
Thank you very much for your answers.

Which ones don't work? If they really do, the articles need fixes, so tell us your experience precisely.

To cross compile TO windows, both 32-bit and 64-bit, no additional packages required. Every requirement is built into the compiler toolchain AND its source code, which you must build for EACH requested target first, and that what the cross compiling article should tell you how to.

I tried this tutorial for example : http://wiki.lazarus.freepascal.org/Cross_compiling_for_Win32_under_Linux

are you in the right directory?
have you permissions?

Code: Bash  [Select][+][-]
  1.  
  2. $ cd /usr/share/fpcsrc/3.0.0
  3. $ sudo make all OS_TARGET=win32 CPU_TARGET=i386
  4.  

if you install with the .deb available from the lazarus download link page, edit yout /etc/fpc.cfg file and include the following instructions:
Code: Bash  [Select][+][-]
  1. -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget
  2. -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/*
  3. -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl
  4.  

I tried it again with root permission, but I got still the message that there is no rule for creating "all".

Here the content of

/usr/share/fpcsrc/3.0.0$ ls -al

drwxr-xr-x   5 root root  4096 Okt 13 20:52 .
drwxr-xr-x   3 root root  4096 Okt 13 20:51 ..
drwxr-xr-x  22 root root 12288 Okt 13 20:52 compiler
drwxr-xr-x 127 root root  4096 Okt 13 20:52 packages
drwxr-xr-x  57 root root  4096 Okt 13 20:52 rtl

And I installed Lazarus using apt-get, so I don't have the file /etc/fpc.cfg

I will uninstall everything and try the installation package from the lazarus page.

bylaardt

  • Sr. Member
  • ****
  • Posts: 310
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #4 on: October 14, 2016, 09:17:29 pm »
I installed Lazarus using apt-get, so I don't have the file /etc/fpc.cfg

I will uninstall everything and try the installation package from the lazarus page.
perhaps apt-get have a stripped version of fpc.

my ls results:
Code: Bash  [Select][+][-]
  1. $ ls -al
  2. total 164
  3. drwxr-xr-x   9 root root  4096 Set 15 13:05 .
  4. drwxr-xr-x   3 root root  4096 Set 15 09:36 ..
  5. drwxr-xr-x  25 root root 28672 Out 14 13:34 compiler
  6. -rw-rw-r--   1 root root   254 Jun  2  2013 fpmake_add1.inc
  7. -rw-rw-r--   1 root root  1189 Jun  2  2013 fpmake.pp
  8. -rw-rw-r--   1 root root   194 Jun  2  2013 fpmake_proc1.inc
  9. drwxr-xr-x   4 root root 12288 Set 15 13:05 ide
  10. drwxr-xr-x   2 root root  4096 Set 15 13:05 installer
  11. -rw-rw-r--   1 root root 71668 Dez  5  2015 Makefile
  12. -rw-rw-r--   1 root root  9602 Dez  5  2015 Makefile.fpc
  13. drwxr-xr-x 131 root root  4096 Out 14 13:34 packages
  14. drwxr-xr-x  59 root root  4096 Out 14 13:34 rtl
  15. drwxr-xr-x  10 root root  4096 Set 15 13:05 tests
  16. drwxr-xr-x  27 root root  4096 Set 15 13:05 utils
  17.  

Rainer78

  • New Member
  • *
  • Posts: 10
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #5 on: October 14, 2016, 09:45:06 pm »
perhaps apt-get have a stripped version of fpc.

I think so, too. Now I have installed the following packages (in the same order as written below) with apt-get install ./<filename>

- fpc_3.0.0-151205_amd64.deb
- fpc-src_3.0.0-151205_amd64.deb
- lazarus_1.6-0_amd64.deb

Now I have the same files like you and could run the commands from the tutorial page (http://wiki.lazarus.freepascal.org/Cross_compiling_for_Win32_under_Linux), too.

After building the files for win32 and win64, I added the three lines to /etc/fpc.cfg.

Now I can compile for win64, but not for win32. If I select win32, I get an error, that the current FPC has no configuration file, som units might not be found and I should check my FPC-installation.

I tried my win64 application on a Windows 10 x64 notebook, but I got the error message, that th program could not be started because libgdk_pixbuf-2.0-0.dll (libgtk-win32-2.0-0.dll, libgdk-win32-2.0-0.dll, libobject-2.0-0.dll ) is missing. I am wondering why I got this message because I set the LCL-Widgetset to Win32. I changed the LCL-Widgetset to "qt", but I got the same error.

Any hints for my "new" problems? ... building win32 application and running them under Windows OS?

Handoko

  • Hero Member
  • *****
  • Posts: 5515
  • My goal: build my own game engine using Lazarus
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #6 on: October 15, 2016, 02:54:27 am »
Hello Rainer78. I'm an Ubuntu user too. I ever had bad experience using Lazarus downloaded from Ubuntu repository, so after that I always use Lazarus downloaded from:

http://www.lazarus-ide.org/index.php?page=downloads

Once I managed to make something work correctly, I like to write it down the how to procedure. And these are the steps I use to install Lazarus/FPC on Ubuntu Mate 64 bit:

Quote
01. Uninstall lazarus, fpc, fpc-src (if it's already installed)
02. Delete ~/.lazarus, except: editoroptions, environmentoption
04. Delete /etc/fp.*
03. Delete /usr/share/fpcsrc
05. Delete /usr/lib/fpc
06. Delete /usr/bin/ppc*
07. Install fpc_3.0.0-151205_amd64.deb
08. Install fpc-src_3.0.0-151205_amd64.deb
09. Install lazarus_1.6-0_amd64.deb

Note:
The steps above may need to be modify to suit your environment, especially the deb file names. You have to download and install all the 3 deb files. I intentionally keep the editoroptions and environmentoption because I modify several IDE settings.

And these are the things I do to make it cross compile to Win32:

Quote
01. cd /usr/share/fpcsrc/3.0.0
02. sudo make clean all OS_TARGET=win32 CPU_TARGET=i386
03. sudo make crossinstall OS_TARGET=win32 CPU_TARGET=i386 INSTALL_PREFIX=/usr
04. sudo ln -sf /usr/lib/fpc/3.0.0/ppcross386 /usr/bin/ppcross386
« Last Edit: October 15, 2016, 02:59:54 am by Handoko »

Rainer78

  • New Member
  • *
  • Posts: 10
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #7 on: October 15, 2016, 08:41:06 am »
Hello Handoko,

I removed everything and started from the scratch using your instructions. Because of you INSTALL_PREFIX=/usr it is not necessary to modify the file /etc/fpc.cfg. Is this correct?

After running your commands I run the same again using OS_TARGET=win64 CPU_TARGET=x86_64

This works fine, too.

Now I tried to compile my Hello world project again.

If the target is "default", the build runs perfect for linux / Ubuntu.

If the target is "win64", the build runs perfect, too and runs without any additional lib files.

If the target is "win32", the confirmation failed with the an error message (some units are missing) and when I tried to build the project, I got the folowing output "Error: Illegal parameter: -Twin32"

Any more hints? Do I need to install the 32bit version of lazarus or fpc / fpc-source, too?

Best regards,

Rainer
« Last Edit: October 15, 2016, 08:52:17 am by Rainer78 »

Handoko

  • Hero Member
  • *****
  • Posts: 5515
  • My goal: build my own game engine using Lazarus
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #8 on: October 15, 2016, 04:03:23 pm »
The ability to target to Win64 and the ability to target Win32 are 2 different things.

You now able to create Win64 executable files, right.

So, to be able to target to Win32, just do it again as the instruction I gave you, I meant don't change the OS_TARGET dan CPU_TARGET.

Rainer78

  • New Member
  • *
  • Posts: 10
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #9 on: October 15, 2016, 08:40:45 pm »
Yes, I am able to create a Win64 application.

I made the steps of you again, they run all correct without any error, but it still doesn't work. I attached three screenshots (sorry, but they are in German language ;-) ).

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #10 on: October 15, 2016, 09:32:47 pm »
Yes, I am able to create a Win64 application.

I made the steps of you again, they run all correct without any error, but it still doesn't work. I attached three screenshots (sorry, but they are in German language ;-) ).
win32 is not a valid target for your default CPU (x86_64), modify it to i386. Assuming you did what Handoko said, that's the only problem left.

Rainer78

  • New Member
  • *
  • Posts: 10
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #11 on: October 15, 2016, 10:52:49 pm »
My problem is / was, that there was no ppc386 file on my system. I tried the following and it seems to work.

sudo ln -sf /usr/lib/fpc/3.0.0/ppcross386 /usr/bin/ppc386

After this there was no error message any more. I set thetTarget-OS to win32 and the target-cpu-family to i386 and I could compile without any problems.

Is it correct, that I use the ppcross386 instead of a "real" ppc386?

If so, I think it could be helpful to others, if my "problems" were mentioned in the tutorial? For example that if the apt-get package of fpc-source is installed, the "make ..." commands cannot be started.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #12 on: October 16, 2016, 01:28:10 am »
My problem is / was, that there was no ppc386 file on my system.
You're building a cross compiler, which has ppcross prefix instead of pp.
I tried the following and it seems to work.

sudo ln -sf /usr/lib/fpc/3.0.0/ppcross386 /usr/bin/ppc386
Better name the symlink the way the original file is. I don't really want to read how fpc searches for the compiler binary, but I guess it will try to look for ppXXX if ppcrossXXX is not found.
If so, I think it could be helpful to others, if my "problems" were mentioned in the tutorial? For example that if the apt-get package of fpc-source is installed, the "make ..." commands cannot be started.
Feel free to add it, the wiki is open for everyone. Note that distribution specific package problem is distribution specific, don't generalize it as a Linux problem, say Debian derivatives instead (and I guess it's rather new, could be a packaging bug as well).

Rainer78

  • New Member
  • *
  • Posts: 10
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #13 on: October 16, 2016, 07:50:26 am »
@all of you:
Thank you very much for your help. I will make some more tests and after that I will add my informations to thensure wiki.

Rainer78

  • New Member
  • *
  • Posts: 10
Re: IDE under Ubuntu Crosscompile to Windows
« Reply #14 on: October 23, 2016, 11:19:16 am »
Finally I made some tests and here are my results:

1. The package fpc-source-3.0.0_3.0.0+dfsg-2_all.deb I got via "apt-get install lazarus" doesn't contain all files I need. I don't know where to report this, that the official package will be modified.

2. Running the installation steps of Handoko, the cross compile works fine (with my modification of the link to ppc386)

3. When I installed everything manually, I got some errors when I run "apt-get install dist-upgrade". It is trying to "update" to the official fpc-packages again and that fails.

Has someone of you any hints, how to fix this problem?

Regards,

Rainer

[edit] dist-upgrade command modified
« Last Edit: October 23, 2016, 12:31:29 pm by Rainer78 »

 

TinyPortal © 2005-2018