Is it possible to write a simple native executable, which can be run in Windows Linux and Mac OSX and the only thing it will do is to check what is the system and run adequate (another) program compiled for this platform?
I want simply to create an installer, which user will download independently of the platform he is using, which will automaticaly discover the platform and unpack (from itself) installer for this particular platform.
Related
I am not sure if this is a Programming or Linux question so please forgive me! Here is my situation:
I have my own PC (running Lubuntu 64 19.04) which I use as my work desktop. I have installed qt creator and qt 5.13 and everything works fine.
Now I have a mini-pc (intel nuc) which is luckily the same CPU architecture (intel x86-64). So the program will be binary compatible for both machines and allows me to develope and compile on my main machine and then remotely deploy or debug on the mini-pc using something like ssh and scp.
I want to develope some sort of "kiosk" application for this mini-pc. The problem is that it has very little storage (32GB). This kiosk application will save some data so it needs a lot of free space.
Now back to the question: For the mini-pc, I can go with qt-installer and install qt just like how I did it on my desktop. But I want to avoid this and I want only to copy the libraries that my application needs to have as small as footprint possible. So:
Is there a qt 5.13 libraries only package that I can install using
apt-get?
Can I get away with only copying (.so or .a) files to my remote pc
in the application binary folder?
What would be the must professional way?
You can copy only the relevant dependencies. There is a existing project for this purpose, called linuxdeployqt.
According to the official docs:
This Linux Deployment Tool, linuxdeployqt, takes an application as input and makes it self-contained by copying in the resources that the application uses (like libraries, graphics, and plugins) into a bundle.
And more specific:
When used on Qt-based applications, it can bundle a specific minimal subset of Qt required to run the application.
The project is based in the official tool macdeployqt.
I'm using the lastest DELPHI version 10.2.3 with LINUX support and I already managed to compile a console application using the platform LINUX 64 bit and execute this code on my UBUNTU client computer.
Now I wanted to convert a larger project for LINUX.
Question is now : for a exsting DLL which compiles fine for with WIN64, how to add now LINUX support, the add platform buttom in Delphi does not provide the LINUX 64 BIT platform for the existing project
It is not possible to add platform, that wasn't available, when project was created. To fix this, you will need to delete dproj-file and let IDE recreate it.
I've seen several tutorials on how to compile C++ applications for Windows on a linux system, however, I have failed to find a way to use Windows specific headers (i.e Windows.h) in my C++ program to compile for Windows (.exe/.dll). I was wondering if anyone knew how I can compile Visual C++ programs on Linux that use Windows OS Specific headers/functions (just compile). Thanks!
You can't. Windows system headers, e.g. windows.h reference OS specific APIs that are not known to Linux. Only Microsoft's compiler can create Windows format objects and executables and it doesn't run on Linux.
You can create cross-platform applications consisting of common code that will build and run on Windows and Linux. But the only way to use platform specific APIs in such an application, e.g. GUI, is to #define sections in/out according to the build environment.
I have developed a small application in Qt Creator on Ubuntu 12.04 which I want should run on any other linux distro (mostly different versions of CentOS and ubuntu), just like any portable application on windows does.
I want to be able to simply share the binary file of the Application, and run the application.
I am able to successfully do this in windows, by just building the project in QT Creator and then putting the required libraries in the Application directory and then transfering them to other windows systems.
I searched all over and found out that I should be trying to build the project using LSB(Linux Standard Base) Compatibility, so that it runs on other linux distros. Is that the right way to do this?
I am very new to Qt and also to Linux (dont know much of Shell Scripting).
Thus, I dont know how I should proceed to make the Application LSB Compliant.
I have refered to, the following links:
Distributing Qt-based binaries on Linux and
Deploying Qt applications on Linux but have not beem able to understand what I am suposed to do.
I also found this question here which states a very similar situation as mine, but because I am a novice, I dont know how I should do this.
Moreover, considering that the first two articles were written 6 years back, shouldn't there be a simpler way to deploy Qt apps on the linux platform now?
I also saw something about static linking, is that the way to go?
Isn't there a way by which all of this can be done through Qt Creator itself?
If there is no hope of creating a portable Qt Application for Linux, then is there a way, say a shell script or something that would combine all the steps required to compile the Qt project on another computer and run it. Say, download Qt-SDK if not present, run qmake and make and then the newly compiled application, if not already there, so that the user can run the program just by running one script.
Your problem here is not the Linux Standard Base, but rather the presence or not of the specific version of Qt you need (or a later one).
Exactly like on a Windows machine, a user may have any of Qt installed, or they may not have it at all. On Windows it is easier to check for the presence of a certain version of Qt than it is on Linux, thus it is easier to write install tools that automate the experience.
To solve your problem there are a few ways:
Inform the user that your program requires a certain version of Qt or higher, and let the user handle the problem
Learn how to create packages for every distribution you want to target and create specific packages
Use a program like 0Install or Elf Statifier to create a package/executable containing all the necessary libraries.
The latter is similar to what many Windows and Mac programs do (they include every library they need within the installer), but it is not the preferred way on Linux, which relies heavily on shared libraries.
Making a binary application compatible with any other Linux distro is practically impossible since you will never know in advance which libraries are available in distro X, or what version of that library is available. Even among a single distro (e.g. Ubuntu), binary application are almost never backward-compatible, since anything built on Ubuntu 12.04 will have dependencies on versions libraries which are installed on that version of Ubuntu, and trying to run that binary on Ubuntu 10.04 will most probably fail simply because it doesn't have a recent enough version of glibc or some other necessary library.
However, the idea can be much more implementable if you limit yourself to a finite list of distros and versions of those distros. You can then know which libraries are available for those distros, and aim for the lowest common denominator. I used to maintain a binary application which had to support several distros (Ubuntu, Fedora, OpenSUSE, SLED, Mandriva), and the way I would do it is install the oldest distro I was targeting on my build machine. That way, the binary application would be linked to the oldest versions of the libraries available on those distros. Unless there's a new major version of such a library (which happens quite rarely, and even then, distros usually distribute the previous major version for a while for compatibility purposes), your compiled binary will then be compatible with all your targeted distros.
Therefore, the quick piece of advice I would give for your situation, use the oldest LTS version of Ubuntu which is still supported (10.04 at the moment) for your development, and you should be pretty safe for most recent popular distros. For the application you already developped on Ubuntu 12.04, you should have no problem simply recompiling the same source on 10.04. Understand that you will never however achieve 100% compatibility with a compiled C++ Qt application.
If Qt is not all that important to you, you could use a higher-level or interpreted language such as Python, Java, Perl or Ruby. With such languages, you can usually count on the language implementation already being installed on the target distro.
Deploy an application in Linux is a nightmare, luckily there are some solutions. Check this projects to build a portable binary with all their dependencies bundled:
http://statifier.sourceforge.net/statifier/main.html
http://www.magicermine.com/index.html
http://www.pgbovine.net/cde.html
Another solution is make a portable 0install package:
http://0install.net/
I recomend this solution. Personally I have been problems with the 3 first packagers.
Does NSIS support Linux and Solaris? I read somewhere that we can compile nsis script on Linux but cant execute the .exe generated on any other platforms but Windows. Can somebody put more light in this?
No.
See the NSIS feature list for more information ...
Portable Compiler
The NSIS compiler can be compiled for POSIX platforms like
Linux and *BSD. Generated installer
will still run on Windows only, but
this way they can be generated without
Windows or WINE.
You can compile installers on POSIX and Windows systems, but it always produces a Win32 PE file that only runs on Windows (And maybe under WINE on *nix)
Check the NSIS manual for more info
The installer systems for Windows and Linux are completely different.
Whereas Windows' only contribution to a software management system is one registry entry pointing to the uninstaller, Linux has a full working software management system. There are apt, yum, pacman and many more out there, which are supporting many more features and possibilities including automatic execution of scripts and pulling in/installing dependencies. If you have a cross platform application you wanna share, you're either stuck with creating a tar-ball, or you learn how to build deb/rpm etc. packages.
Linux and Windows are not binary compatible, so you can't do that.
But, most of the windows binary installer could able to install at WINE