Lazarus
Free Pascal => Beginners => Topic started by: QuinnMartin on August 15, 2022, 07:01:09 pm
-
Sorry this may be a dumb question, but is it easy to use the very same Lazarus installation and source code to compile both a Windows x32 and x64 executable? Or does this require digging into configuration settings or FPC libraries and modifying stuff? I did a cursory search and keep finding a lot of posts from 2010-2015 which may not be relevant now.
I would like to offer my users both a x32 and x64 executable, but will just stick with one if the process is complicated.
-
Yes, it is easy.
-
Can I build x64 executables from 32-bit Lazarus, or do I need 64-bit Lazarus to do both?
-
I use Linux, not much I can say for Windows. But this maybe can help you:
https://wiki.lazarus.freepascal.org/Cross_compiling#From_win32_to_win64
-
also simple in the IDE "options for project" (the gear icon on the 2nd line next to the green play button), you can setup different "build modes". I tend to have 4, two for 32 bit (debug and release) and two more for 64 bit. Once you have your build modes defined, go to the "config and target" option and set your target for each. win64 or win32 as an example.
-
Can I build x64 executables from 32-bit Lazarus, or do I need 64-bit Lazarus to do both?
https://forum.lazarus.freepascal.org/index.php/topic,59386.msg442705.html#msg442705
-
Sorry this may be a dumb question, but is it easy to use the very same Lazarus installation and source code to compile both a Windows x32 and x64 executable? Or does this require digging into configuration settings or FPC libraries and modifying stuff?
It essentially boils down to installing the corresponding addon for your IDE (if you have the i386-win32 one you need to install the x86_64-win64 addon and vice versa). After that you only need to set the correct target in your project settings.
-
Thank you very much, I think it's starting to make a little more sense now.
The one thing I can't figure out is compiling a Linux executable in a Win32 environment. Is this realistic, or should all Linux executables be built under Lazarus in Linux? I'm trying to avoid an overly complicated setup, and some of the instructions I found were over my head.
-
You need to build FPC yourself in that case (so that you have the RTL and FCL available). For that you need the correct binutils. Also you need to have all required library available on your build system, because that's how linking on *nix systems work (for e.g. the Windows targets the libraries aren't required). It might be that fpcupdeluxe can help you here, but I can't say for sure, because I don't use it.
In the end it might be best to compile in a Linux distribution or - if you have Windows 10 - by using WSL.
In how far your application is then portable across distributions depends upon what C library the distribution you pick for compilation has. E.g. current Debian and Ubuntu releases use 2.31 which also allows your application to run on systems with a newer C library. But if you compile against e.g. 2.35 (used in current ArchLinux) then it won't be able to run on a system with a 2.31 one (which are still quite common).
-
OK, I appreciate it.. that points me in the right direction. It sounds like I should just write it in Lazarus under Windows (where I do most of my work) and port the project over to a separate Linux Lazarus installation later and compile it there.