1

I have an application written in pure C++ and Qt 5.5.1. It compiles fine in both GCC (Lubuntu 15.10 x86) and MSVC 14.0 (Windows 8.1 x64), and works properly on both those platforms. I now want to distribute it so that it will run on other Linux distros without recompiling them there.

I'm not entirely sure how to achieve this; the Qt docs page generally suggests to link everything statically, but this is not what most other sources say (from what I understand it is a bad idea to link with glibc statically). In any case I cannot really link everything statically because GCC complains that Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking and from what I understand this isn't a warning one can simply ignore. I've tired linking statically against only libgcc and libstdc++, I copied the other missing libraries - libXau.so.6, libXdmcp.so.6 and libxcb.so.1 on a clean CentOS 7 installation and tried to run the program there, but that gave me a segmentation fault; possibly because the system is 64 bit as opposed to the platform I compiled the application on?

  • How can I distribute the application in a form runnable by most common configurations? Static linking is not an issue because the source is going to be released anyway.
  • Is it better to link against Qt statically or dynamically (if maximum binary portability is the priority)?
  • Do I need to provide two separate versions of the binary, 32 and 64 bit, or will a 32 bit build suffice?
user4520
  • 3,401
  • 1
  • 27
  • 50

1 Answers1

1

My suggestion would be to offer two builds: an unsupported, fully static build that will work "anywhere" with an asterisk that there's no way you can support it if it's a commercial offering. People'll try to run it on their fridges, I kid you not. The officially supported builds must be for specific platforms only, and you can't but have VMs/test targets that run these platforms, and where you build and test on.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • `an unsupported, fully static build` - do you mean I should ignore the warning that matching shared libraries are required to be present on the target machine? – user4520 Dec 18 '15 at 20:37
  • @szczurcio - you don't need any libs with static linking – dtech Dec 18 '15 at 21:56
  • 1
    The interface between your fully static build and the target is at the syscall and socket interface level (e.g. for X11 calls). As long as a sensible kernel version, device node layout and X server version is present, your code will "run". – Kuba hasn't forgotten Monica Dec 18 '15 at 22:01
  • @ddriver Please read the question carefully - when linking statically (i.e. passing the `-static` flag to `ld`), you still get a warning that certain shared libraries will be used. See here for more details: http://stackoverflow.com/questions/2725255/create-statically-linked-binary-that-uses-getaddrinfo – user4520 Dec 18 '15 at 22:02