IDE under Ubuntu Crosscompile to Windows lazarus / 1-Linux ---------------------------------------------------------------------- Rainer78 · 2016-10-13 19:54 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 · 2016-10-14 05:00 Quote from: Rainer78 on October 13, 2016, 09:54:36 pmI 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 · 2016-10-14 16:48 Quote from: Rainer78 on October 13, 2016, 09:54:36 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  $ cd /usr/share/fpcsrc/3.0.0$ sudo make all OS_TARGET=win32 CPU_TARGET=i386  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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget-Fu/usr/local/lib/fp c/$fpcversion/units/$fpctarget/*- Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl ---------------------------------------------------------------------- Rainer78 · 2016-10-14 18:19 Thank you very much for your answers. Quote from: Leledumbo on October 14, 2016, 07:00:31 amWhich 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 Quote from: bylaardt on October 14, 2016, 06:48:03 pmare you in the right directory? have you permissions? Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  $ cd /usr/share/fpcsrc/3.0.0$ sudo make all OS_TARGET=win32 CPU_TARGET=i386  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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget-Fu/usr/local/lib/fp c/$fpcversion/units/$fpctarget/*- Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl  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 · 2016-10-14 19:17 Quote from: Rainer78 on October 14, 2016, 08:19:59 pmI 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ ls -altotal 164drwxr-xr-x   9 root root  4096 Set 15 13:05 .drwxr-xr-x   3 root root  4096 Set 15 09:36 ..drwxr-xr-x  25 root root 28672 Out 14 13:34 compiler-rw-rw-r--   1 root root   254 Jun  2  2013 fpmake_add1.inc-rw-rw-r--   1 root root  1189 Jun  2  2013 fpmake.pp- rw-rw-r--   1 root root   194 Jun  2  2013 fpmake_proc1.incdrwxr-xr-x 4 root root 12288 Set 15 13:05 idedrwxr-xr-x   2 root root  4096 Set 15 13:05 installer-rw-rw-r--   1 root root 71668 Dez  5  2015 Makefile-rw-rw-r--   1 root root  9602 Dez  5  2015 Makefile.fpcdrwxr- xr-x 131 root root  4096 Out 14 13:34 packagesdrwxr-xr-x  59 root root  4096 Out 14 13:34 rtldrwxr-xr-x  10 root root  4096 Set 15 13:05 testsdrwxr-xr-x  27 root root  4096 Set 15 13:05 utils ---------------------------------------------------------------------- Rainer78 · 2016-10-14 19:45 Quote from: bylaardt on October 14, 2016, 09:17:29 pmperhaps 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 ./ - 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 · 2016-10-15 00:54 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: Quote01. 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: Quote01. 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 ---------------------------------------------------------------------- Rainer78 · 2016-10-15 06:41 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 ---------------------------------------------------------------------- Handoko · 2016-10-15 14:03 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 · 2016-10-15 18:40 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 · 2016-10-15 19:32 Quote from: Rainer78 on October 15, 2016, 08:40:45 pmYes, 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 · 2016-10-15 20:52 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 · 2016-10-15 23:28 Quote from: Rainer78 on October 15, 2016, 10:52:49 pmMy 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. Quote from: Rainer78 on October 15, 2016, 10:52:49 pmI 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. Quote from: Rainer78 on October 15, 2016, 10:52:49 pmIf 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 · 2016-10-16 05:50 @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 · 2016-10-23 09:19 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 ---------------------------------------------------------------------- Thaddy · 2016-10-23 09:25 What is distupgrade? that should be dist-upgrade.... ---------------------------------------------------------------------- Rainer78 · 2016-10-23 10:32 Sorry, my mistake. I mean dist-upgrade. But the error is still the same ;-) ---------------------------------------------------------------------- bylaardt · 2016-10-24 16:34 Ubuntu believes fpc3.0.0+dfsg-2 is newest than fpc3.0.0. my Workarround : Change name to fpc3.0.0+fixed Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ mkdir tmp$ sudo dpkg-deb -R ./fpc_3.0.0-151205_amd64.deb ./tmp$ sudo kate ./tmp/DEBIAN/control      //or another editor, like gedit and change version from 3.0.0 to 3.0.0+fixed$ sudo dpkg-deb -b tmp ./fpc_3.0.0-fixed.deb $ sudo cp /etc/fpc.bak /etc/fpc.cfg $ sudo rm tmp -R$ sudo mkdir tmp$ sudo dpkg-deb -R ./lazarus_1.6-0_amd64.deb tmp$ sudo kate ./tmp/DEBIAN/control      //change version from 1.6 to 1.6+fixed$ sudo dpkg-deb -b tmp ./lazarus_1.6-0-fixed.deb $ sudo rm tmp -R$ sudo dpkg -i ./fpc_3.0.0-fixed.deb ./lazarus_1.6-0-fixed.deb ---------------------------------------------------------------------- Rainer78 · 2016-10-24 19:32 Thank you very much for your workaround. I rebuild the fpc-src package new, too. This all and my modified ln command made everything fine. This topic can be closed now ---------------------------------------------------------------------- Jay · 2016-11-01 09:34 I am also having a problem trying to compile for Windows under Linux. I'm using a Debian (stable) based distro (32 bit) and installed Lazarus from the Deb (version 1.6/3.0). I have successfully set up the system by running Quotemake all OS_TARGET=win32 CPU_TARGET=i386 from /usr/share/fpcsrc/3.0.0 At least, I assume it was successful because I didn't get any errors. Next, I started a new "simple program" from Lazarus : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;begin  writeln('Hello, world!');end. I then went to project/project options/compiler options/ and selected Target OS = win32 Target CPU family = i386 Target Processor = default After running "compile", I got the following error message: QuoteFatal: Can't find unit system used by Project1 Any suggestions? By the way, this isn't a new installation of Lazarus ; I've been compiling for linux with it for some time with no problems, so the error is specific to the win32 target. Edit: Don't know if this is relevant, but during the "make all" step there were several messages - QuoteWarning : Unable to determine the libgcc path. ---------------------------------------------------------------------- Thaddy · 2016-11-01 10:35 No. the libgcc path is for a different purpose and not related. That warning is an issue, however. The intended behavior for debugging is GDBMI as of now. Not linking in libgdb. Correct me if I am wrong. ---------------------------------------------------------------------- Leledumbo · 2016-11-01 11:04 Quote from: Jay on November 01, 2016, 10:34:20 amAny suggestions? You only make the cross compiler toolchain, not yet install it. ---------------------------------------------------------------------- Jay · 2016-11-01 12:35 Quote from: Leledumbo on November 01, 2016, 12:04:32 pmYou only make the cross compiler toolchain, not yet install it. Ok thanks. Is that just a matter of doing Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i sudo make install from the source folder? ---------------------------------------------------------------------- Leledumbo · 2016-11-01 12:55 Quote from: Jay on November 01, 2016, 01:35:53 pmQuote from: Leledumbo on November 01, 2016, 12:04:32 pmYou only make the cross compiler toolchain, not yet install it. Ok thanks. Is that just a matter of doing Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i sudo make install from the source folder? You'll still need to pass CPU_TARGET and OS_TARGET AFAIK, along with INSTALL_PREFIX for base installation directory (defaults to /usr/local if not passed). Under Linux environment, if your native fpc is installed under /usr, I recommend the same for INSTALL_PREFIX as you can have single unified fpc.cfg for all targets without too many -Fu lines. ---------------------------------------------------------------------- Jay · 2016-11-01 13:30 Thanks. I messed up again but then re-installed Lazarus and followed the instructions on the wiki to the letter. It's all good now. I guess when all fails RTFM.